Thu, 09 Jul 2015 17:22:55 +0200
-a option wasn't working correctly in recursive mode
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 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2015 Olaf Wintermann. All rights reserved. |
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> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <ucx/utils.h> |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
34 | #include <ucx/map.h> |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | #include "davqlexec.h" |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
36 | #include "utils.h" |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
37 | #include "methods.h" |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
38 | #include "session.h" |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
39 | #include "resource.h" |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
41 | DavResult dav_statement_exec(DavSession *sn, DavQLStatement *st, ...) { |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | va_list ap; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | va_start(ap, st); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
44 | DavResult result = dav_statement_execv(sn, st, ap); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | va_end(ap); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
49 | 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
|
50 | DavResult result; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
51 | result.result = NULL; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
52 | result.status = 1; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | // make sure the statement was successfully parsed |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | if(st->type == DAVQL_ERROR) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
56 | DavResult result; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
127
7072a2b4ae35
renamed GET to SELECT in davql syntax
Mike Becker <universe@uap-core.de>
parents:
126
diff
changeset
|
60 | if(st->type == DAVQL_SELECT) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
61 | return dav_exec_select(sn, st, ap); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | // TODO |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
69 | sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list ap, davqlerror_t *error) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
70 | UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | int placeholder = 0; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
73 | for(int i=0;i<fstr.length;i++) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
74 | char c = fstr.ptr[i]; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | if(placeholder) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | // no placeholder, %% transposes to % |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
78 | ucx_buffer_putc(buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | // detect placeholder type and insert arg |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | int err = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | switch(c) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | case 's': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | char *arg = va_arg(ap, char*); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
85 | ucx_buffer_puts(buf, arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | case 'd': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | int arg = va_arg(ap, int); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
90 | ucx_bprintf(buf, "%d", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | case 'u': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | unsigned int arg = va_arg(ap, unsigned int); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
95 | ucx_bprintf(buf, "%u", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | case 't': { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
99 | // time arguments not supported for strings |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | default: { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | *error = DAVQL_UNKNOWN_FORMATCHAR; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | if(err) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
109 | ucx_buffer_free(buf); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
110 | sstr_t n; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
111 | n.ptr = NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
112 | n.length = 0; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
113 | return n; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | placeholder = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | placeholder = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | } else { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
121 | ucx_buffer_putc(buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | *error = DAVQL_OK; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
126 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
127 | return sstrdup_a(a, sstrn(buf->space, buf->size)); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
130 | static int fl_add_properties(DavSession *sn, UcxMempool *mp, UcxMap *map, DavQLExpression *expression) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
131 | if(!expression) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
132 | return 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
133 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
134 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
135 | if(expression->type == DAVQL_IDENTIFIER) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
136 | DavProperty *property = ucx_mempool_malloc(mp, sizeof(DavProperty)); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
137 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
138 | char *name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
139 | DavNamespace *ns = dav_get_property_namespace( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
140 | sn->context, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
141 | sstrdup_a(mp->allocator, expression->srctext).ptr, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
142 | &name); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
143 | if(!ns) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
144 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
145 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
146 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
147 | property->ns = ns; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
148 | property->name = name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
149 | property->value = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
150 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
151 | ucx_map_sstr_put(map, expression->srctext, property); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
152 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
153 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
154 | if(expression->left) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
155 | if(fl_add_properties(sn, mp, map, expression->left)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
156 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
157 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
158 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
159 | if(expression->right) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
160 | if(fl_add_properties(sn, mp, map, expression->right)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
161 | return -1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
162 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
163 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
164 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
165 | return 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
166 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
167 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
168 | static UcxBuffer* fieldlist2propfindrequest(DavSession *sn, UcxMempool *mp, UcxList *fields, int *isallprop) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
169 | UcxMap *properties = ucx_map_new(32); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
170 | *isallprop = 0; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
171 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
172 | UCX_FOREACH(elm, fields) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
173 | DavQLField *field = elm->data; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
174 | if(!sstrcmp(field->name, S("*"))) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
175 | ucx_map_free(properties); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
176 | *isallprop = 1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
177 | return create_allprop_propfind_request(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
178 | } else if(!sstrcmp(field->name, S("-"))) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
179 | ucx_map_free(properties); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
180 | return create_basic_propfind_request(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
181 | } else { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
182 | if(fl_add_properties(sn, mp, properties, field->expr)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
183 | // TODO: set error |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
184 | return NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
185 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
186 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
187 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
188 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
189 | UcxMapIterator i = ucx_map_iterator(properties); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
190 | UcxKey key; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
191 | DavProperty *value; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
192 | UcxList *list = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
193 | UCX_MAP_FOREACH(key, value, i) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
194 | list = ucx_list_append(list, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
195 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
196 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
197 | UcxBuffer *reqbuf = create_propfind_request(sn, list); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
198 | ucx_list_free(list); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
199 | return reqbuf; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
200 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
201 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
202 | static int reset_properties(DavSession *sn, DavResult *result, DavResource *res, UcxList *fields) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
203 | UcxMap *new_properties = ucx_map_new_a(sn->mp->allocator, 32); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
204 | DavResourceData *data = (DavResourceData*)res->data; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
205 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
206 | // add basic properties |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
207 | char *value; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
208 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
209 | UcxKey cl_key = dav_property_key("DAV:", "getcontentlength"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
210 | value = ucx_map_get(data->properties, cl_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
211 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
212 | ucx_map_put(new_properties, cl_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
213 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
214 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
215 | UcxKey cd_key = dav_property_key("DAV:", "creationdate"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
216 | value = ucx_map_get(data->properties, cd_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
217 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
218 | ucx_map_put(new_properties, cd_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
219 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
220 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
221 | UcxKey lm_key = dav_property_key("DAV:", "getlastmodified"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
222 | value = ucx_map_get(data->properties, lm_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
223 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
224 | ucx_map_put(new_properties, lm_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
225 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
226 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
227 | UcxKey ct_key = dav_property_key("DAV:", "getcontenttype"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
228 | value = ucx_map_get(data->properties, ct_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
229 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
230 | ucx_map_put(new_properties, ct_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
231 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
232 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
233 | UcxKey rt_key = dav_property_key("DAV:", "resourcetype"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
234 | value = ucx_map_get(data->properties, rt_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
235 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
236 | ucx_map_put(new_properties, rt_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
237 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
238 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
239 | UcxKey cn_key = dav_property_key("DAV:", "crypto-name"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
240 | value = ucx_map_get(data->properties, cn_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
241 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
242 | ucx_map_put(new_properties, cn_key, value); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
243 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
244 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
245 | UcxKey ck_key = dav_property_key("DAV:", "crypto-key"); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
246 | value = ucx_map_get(data->properties, ck_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
247 | if(value) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
248 | ucx_map_put(new_properties, ck_key, value); |
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 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
251 | // add properties from field list |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
252 | UCX_FOREACH(elm, fields) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
253 | DavCompiledField *field = elm->data; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
254 | DavQLStackObj field_result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
255 | if(!dav_exec_expr(field->code, res, &field_result)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
256 | sstr_t str; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
257 | str.ptr = NULL; |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
258 | str.length = 0; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
259 | if(field_result.type == 0) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
260 | str = ucx_asprintf( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
261 | sn->mp->allocator, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
262 | "%d", |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
263 | field_result.data.integer); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
264 | } else { |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
265 | if(field_result.data.string) { |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
266 | str = sstrdup_a(sn->mp->allocator, sstrn( |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
267 | field_result.data.string, |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
268 | field_result.length)); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
269 | } |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
270 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
271 | if(str.ptr) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
272 | UcxKey key = dav_property_key(field->ns, field->name); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
273 | ucx_map_put(new_properties, key, str.ptr); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
274 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
275 | } else { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
276 | // TODO: error |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
277 | resource_free_properties(sn, new_properties); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
278 | return -1; |
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 | } |
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 | ucx_map_remove(data->properties, cl_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
283 | ucx_map_remove(data->properties, cd_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
284 | ucx_map_remove(data->properties, lm_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
285 | ucx_map_remove(data->properties, ct_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
286 | ucx_map_remove(data->properties, rt_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
287 | ucx_map_remove(data->properties, cn_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
288 | ucx_map_remove(data->properties, ck_key); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
289 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
290 | resource_free_properties(sn, data->properties); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
291 | data->properties = new_properties; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
292 | |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
293 | free(cl_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
294 | free(cd_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
295 | free(lm_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
296 | free(ct_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
297 | free(rt_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
298 | free(cn_key.data); |
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
299 | free(ck_key.data); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
300 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
301 | return 0; |
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 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
304 | /* |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
305 | * 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
|
306 | */ |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
307 | DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
308 | UcxMempool *mp = ucx_mempool_new(128); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
309 | DavResult result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
310 | result.result = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
311 | result.status = 1; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
312 | |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
313 | int isallprop; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
314 | UcxBuffer *rqbuf = fieldlist2propfindrequest(sn, mp, st->fields, &isallprop); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
315 | if(!rqbuf) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
316 | ucx_mempool_destroy(mp); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
317 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
318 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
319 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
320 | // compile field list |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
321 | UcxList *cfieldlist = NULL; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
322 | UCX_FOREACH(elm, st->fields) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
323 | DavQLField *field = elm->data; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
324 | if(sstrcmp(field->name, S("*")) && sstrcmp(field->name, S("-"))) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
325 | // compile field expression |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
326 | UcxBuffer *code = dav_compile_expr( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
327 | sn->context, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
328 | mp->allocator, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
329 | field->expr, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
330 | ap); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
331 | if(!code) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
332 | // TODO: set error string |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
333 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
334 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
335 | DavCompiledField *cfield = ucx_mempool_malloc( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
336 | mp, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
337 | sizeof(DavCompiledField)); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
338 | |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
339 | char *ns; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
340 | char *name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
341 | dav_get_property_namespace_str( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
342 | sn->context, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
343 | sstrdup_a(mp->allocator, field->name).ptr, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
344 | &ns, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
345 | &name); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
346 | if(!ns || !name) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
347 | // TODO: set error string |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
348 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
349 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
350 | cfield->ns = ns; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
351 | cfield->name = name; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
352 | cfield->code = code; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
353 | cfieldlist = ucx_list_append_a(mp->allocator, cfieldlist, cfield); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
354 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
355 | } |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
356 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
357 | // get path string |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
358 | davqlerror_t error; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
359 | sstr_t path = dav_format_string(mp->allocator, st->path, ap, &error); |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
360 | if(error) { |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
361 | // TODO: cleanup |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
362 | return result; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
363 | } |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
364 | |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
365 | int depth = st->depth == DAV_DEPTH_PLACEHOLDER ? va_arg(ap, int) : st->depth; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
366 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
367 | UcxBuffer *where = dav_compile_expr(sn->context, mp->allocator, st->where, ap); |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
368 | if(st->where && !where) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
369 | ucx_mempool_destroy(mp); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
370 | return result; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
371 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
372 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
373 | 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
|
374 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
375 | UcxList *stack = NULL; // stack with DavResource* elements |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
376 | // initialize the stack with the requested resource |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
377 | DavQLRes *r = ucx_mempool_malloc(mp, sizeof(DavQLRes)); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
378 | r->resource = selroot; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
379 | r->depth = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
380 | stack = ucx_list_prepend(stack, r); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
381 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
382 | // reuseable response buffer |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
383 | UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
384 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
385 | 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
|
386 | 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
|
387 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
388 | // do a propfind request for each resource on the stack |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
389 | while(stack) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
390 | DavQLRes *sr = stack->data; // get first element from the stack |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
391 | stack = ucx_list_remove(stack, stack); // remove first element |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
392 | DavResource *root = sr->resource; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
393 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
394 | util_set_url(sn, dav_resource_get_href(sr->resource)); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
395 | CURLcode ret = do_propfind_request(sn->handle, rqbuf, rpbuf); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
396 | int http_status = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
397 | 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
|
398 | //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
|
399 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
400 | if(ret == CURLE_OK && http_status == 207) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
401 | // propfind request successful, now parse the response |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
402 | char *url = "http://url/"; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
403 | PropfindParser *parser = create_propfind_parser(rpbuf, url); |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
136
diff
changeset
|
404 | // TODO: test if parser is null |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
405 | ResponseTag response; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
406 | int r; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
407 | 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
|
408 | if(r == -1) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
409 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
410 | result.status = -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
411 | // TODO: free resources |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
412 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
413 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
414 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
415 | // the propfind multistatus response contains responses |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
416 | // 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
|
417 | // 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
|
418 | 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
|
419 | // 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
|
420 | // and not a child |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
421 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
422 | // add properties |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
423 | add_properties(root, &response); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
424 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
425 | if(root == selroot) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
426 | // 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
|
427 | // 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
|
428 | // 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
|
429 | // 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
|
430 | // added to the stack. |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
431 | DavQLStackObj where_result; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
432 | if(!dav_exec_expr(where, root, &where_result)) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
433 | if(where_result.data.integer != 0) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
434 | if(!reset_properties(sn, &result, root, cfieldlist)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
435 | continue; |
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 | result.status = -1; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
438 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
439 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
440 | result.status = -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
441 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
442 | 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
|
443 | ucx_list_free(stack); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
444 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
445 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
446 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
447 | DavResource *child = response2resource( |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
448 | sn, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
449 | &response, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
450 | root->path); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
451 | // check where clause |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
452 | DavQLStackObj where_result; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
453 | 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
|
454 | if(where_result.data.integer != 0) { |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
455 | if(!reset_properties(sn, &result, child, cfieldlist)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
456 | resource_add_child(root, child); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
457 | if(child->iscollection && |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
458 | (depth < 0 || depth > sr->depth+1)) |
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 | DavQLRes *rs = ucx_mempool_malloc( |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
461 | mp, |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
462 | sizeof(DavQLRes)); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
463 | rs->resource = child; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
464 | rs->depth = sr->depth + 1; |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
465 | stack = ucx_list_prepend(stack, rs); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
466 | } |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
467 | } else { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
468 | 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
|
469 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
470 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
471 | dav_resource_free(child); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
472 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
473 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
474 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
475 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
476 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
477 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
478 | 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
|
479 | result.result = NULL; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
480 | result.status = -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
481 | 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
|
482 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
483 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
484 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
485 | // reset response buffer |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
486 | ucx_buffer_seek(rpbuf, SEEK_SET, 0); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
487 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
488 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
489 | ucx_mempool_destroy(mp); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
490 | return result; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
491 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
492 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
493 | static int count_func_args(DavQLExpression *expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
494 | int count = 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
495 | DavQLExpression *arg = expr->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
496 | while(arg) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
497 | count++; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
498 | if(arg->op == DAVQL_ARGLIST) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
499 | arg = arg->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
500 | } else { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
501 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
502 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
503 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
504 | return count; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
505 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
506 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
507 | static int add_cmd(DavContext *ctx, UcxAllocator *a, UcxBuffer *bcode, DavQLExpression *expr, va_list ap) { |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
508 | if(!expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
509 | return 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
510 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
511 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
512 | int numcmd = 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
513 | DavQLCmd cmd; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
514 | memset(&cmd, sizeof(DavQLCmd), 0); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
515 | davqlerror_t error; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
516 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
517 | sstr_t src = expr->srctext; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
518 | switch(expr->type) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
519 | case DAVQL_NUMBER: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
520 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
521 | if(src.ptr[0] == '%') { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
522 | cmd.data.integer = va_arg(ap, int); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
523 | } else if(util_strtoint(src.ptr, &cmd.data.integer)) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
524 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
525 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
526 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
527 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
528 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
529 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
530 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
531 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
532 | case DAVQL_STRING: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
533 | cmd.type = DAVQL_CMD_STRING; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
534 | cmd.data.string = dav_format_string(a, src, ap, &error); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
535 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
536 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
537 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
538 | case DAVQL_TIMESTAMP: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
539 | if(src.ptr[0] == '%') { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
540 | cmd.type = DAVQL_CMD_TIMESTAMP; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
541 | cmd.data.timestamp = va_arg(ap, time_t); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
542 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
543 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
544 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
545 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
546 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
547 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
548 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
549 | case DAVQL_IDENTIFIER: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
550 | sstr_t propertyname = sstrchr(src, ':'); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
551 | cmd.type = DAVQL_CMD_RES_IDENTIFIER; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
552 | if(propertyname.length > 0) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
553 | 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
|
554 | char *ns; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
555 | char *name; |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
556 | 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
|
557 | ctx, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
558 | sstrdup_a(a, src).ptr, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
559 | &ns, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
560 | &name); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
561 | if(ns && name) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
562 | 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
|
563 | 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
|
564 | } else { |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
565 | // error |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
566 | return -1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
567 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
568 | } else if(!sstrcmp(src, S("name"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
569 | cmd.data.resprop = DAVQL_RES_NAME; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
570 | } else if(!sstrcmp(src, S("path"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
571 | cmd.data.resprop = DAVQL_RES_PATH; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
572 | } else if(!sstrcmp(src, S("href"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
573 | cmd.data.resprop = DAVQL_RES_HREF; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
574 | } else if(!sstrcmp(src, S("contentlength"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
575 | cmd.data.resprop = DAVQL_RES_CONTENTLENGTH; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
576 | } else if(!sstrcmp(src, S("contenttype"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
577 | cmd.data.resprop = DAVQL_RES_CONTENTTYPE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
578 | } else if(!sstrcmp(src, S("creationdate"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
579 | cmd.data.resprop = DAVQL_RES_CREATIONDATE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
580 | } else if(!sstrcmp(src, S("lastmodified"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
581 | cmd.data.resprop = DAVQL_RES_LASTMODIFIED; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
582 | } else if(!sstrcmp(src, S("iscollection"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
583 | cmd.data.resprop = DAVQL_RES_ISCOLLECTION; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
584 | } else if(!sstrcmp(src, S("true"))) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
585 | cmd.type = DAVQL_CMD_INT; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
586 | cmd.data.integer = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
587 | } else if(!sstrcmp(src, S("false"))) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
588 | cmd.type = DAVQL_CMD_INT; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
589 | cmd.data.integer = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
590 | } else { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
591 | // error, unknown identifier |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
592 | return -1; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
593 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
594 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
595 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
596 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
597 | case DAVQL_UNARY: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
598 | 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
|
599 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
600 | case DAVQL_ADD: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
601 | // noop |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
602 | numcmd = 0; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
603 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
604 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
605 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
606 | cmd.type = DAVQL_CMD_OP_UNARY_SUB; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
607 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
608 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
609 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
610 | case DAVQL_NEG: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
611 | cmd.type = DAVQL_CMD_OP_UNARY_NEG; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
612 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
613 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
614 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
615 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
616 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
617 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
618 | case DAVQL_BINARY: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
619 | 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
|
620 | 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
|
621 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
622 | case DAVQL_ADD: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
623 | cmd.type = DAVQL_CMD_OP_BINARY_ADD; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
624 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
625 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
626 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
627 | cmd.type = DAVQL_CMD_OP_BINARY_SUB; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
628 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
629 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
630 | case DAVQL_MUL: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
631 | cmd.type = DAVQL_CMD_OP_BINARY_MUL; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
632 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
633 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
634 | case DAVQL_DIV: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
635 | cmd.type = DAVQL_CMD_OP_BINARY_DIV; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
636 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
637 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
638 | case DAVQL_AND: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
639 | cmd.type = DAVQL_CMD_OP_BINARY_AND; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
640 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
641 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
642 | case DAVQL_OR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
643 | cmd.type = DAVQL_CMD_OP_BINARY_OR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
644 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
645 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
646 | case DAVQL_XOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
647 | cmd.type = DAVQL_CMD_OP_BINARY_XOR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
648 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
649 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
650 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
651 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
652 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
653 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
654 | case DAVQL_LOGICAL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
655 | 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
|
656 | 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
|
657 | 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
|
658 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
659 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
660 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
661 | case DAVQL_NOT: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
662 | 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
|
663 | cmd.type = DAVQL_CMD_OP_LOGICAL_NOT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
664 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
665 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
666 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
667 | case DAVQL_LAND: { |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
668 | cmd.type = DAVQL_CMD_OP_LOGICAL_AND; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
669 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
670 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
671 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
672 | case DAVQL_LOR: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
673 | 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
|
674 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
675 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR_L; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
676 | DavQLCmd *or_l = (DavQLCmd*)(bcode->space + bcode->pos); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
677 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
678 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
679 | 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
|
680 | or_l->data.integer = nright + 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
681 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
682 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
683 | cmd.data.integer = 0; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
684 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
685 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
686 | numcmd += nleft + nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
687 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
688 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
689 | case DAVQL_LXOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
690 | cmd.type = DAVQL_CMD_OP_LOGICAL_XOR; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
691 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
692 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
693 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
694 | case DAVQL_EQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
695 | cmd.type = DAVQL_CMD_OP_EQ; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
696 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
697 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
698 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
699 | case DAVQL_NEQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
700 | cmd.type = DAVQL_CMD_OP_NEQ; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
701 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
702 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
703 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
704 | case DAVQL_LT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
705 | cmd.type = DAVQL_CMD_OP_LT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
706 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
707 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
708 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
709 | case DAVQL_GT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
710 | cmd.type = DAVQL_CMD_OP_GT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
711 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
712 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
713 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
714 | case DAVQL_LE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
715 | cmd.type = DAVQL_CMD_OP_LE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
716 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
717 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
718 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
719 | case DAVQL_GE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
720 | cmd.type = DAVQL_CMD_OP_GE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
721 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
722 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
723 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
724 | case DAVQL_LIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
725 | cmd.type = DAVQL_CMD_OP_LIKE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
726 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
727 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
728 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
729 | case DAVQL_UNLIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
730 | cmd.type = DAVQL_CMD_OP_UNLIKE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
731 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
732 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
733 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
734 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
735 | break; |
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 | case DAVQL_FUNCCALL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
738 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
739 | case DAVQL_CALL: { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
740 | 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
|
741 | // TODO: count args |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
742 | DavQLExpression *funcid = expr->left; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
743 | if(!funcid && funcid->type != DAVQL_IDENTIFIER) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
744 | // fail |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
745 | return -1; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
746 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
747 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
748 | // numargs |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
749 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
750 | cmd.data.integer = count_func_args(expr); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
751 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
752 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
753 | // TODO: resolve function name |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
754 | cmd.type = DAVQL_CMD_CALL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
755 | cmd.data.func = NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
756 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
757 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
758 | numcmd = 2; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
759 | numcmd += nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
760 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
761 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
762 | case DAVQL_ARGLIST: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
763 | numcmd = 0; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
764 | 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
|
765 | 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
|
766 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
767 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
768 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
769 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
770 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
771 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
772 | return numcmd; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
773 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
774 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
775 | UcxBuffer* dav_compile_expr(DavContext *ctx, UcxAllocator *a, DavQLExpression *lexpr, va_list ap) { |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
776 | UcxBuffer *bcode = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
777 | if(!bcode) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
778 | return NULL; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
779 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
780 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
781 | if(add_cmd(ctx, a, bcode, lexpr, ap) <= 0) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
782 | ucx_buffer_free(bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
783 | return NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
784 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
785 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
786 | return bcode; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
787 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
788 | |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
789 | int dav_exec_expr(UcxBuffer *bcode, DavResource *res, DavQLStackObj *result) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
790 | if(!bcode) { |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
791 | result->type = 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
792 | result->length = 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
793 | result->data.integer = 1; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
794 | return 0; |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
795 | } |
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
796 | |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
797 | size_t count = bcode->pos / sizeof(DavQLCmd); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
798 | DavQLCmd *cmds = (DavQLCmd*)bcode->space; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
799 | |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
800 | // create execution stack |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
801 | size_t stsize = 64; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
802 | size_t stpos = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
803 | DavQLStackObj *stack = calloc(stsize, sizeof(DavQLStackObj)); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
804 | #define DAVQL_PUSH(obj) \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
805 | if(stpos == stsize) { \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
806 | stsize += 64; \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
807 | stack = realloc(stack, stsize * sizeof(DavQLStackObj)); \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
808 | } \ |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
809 | stack[stpos++] = obj; |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
810 | #define DAVQL_PUSH_INT(intval) \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
811 | { \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
812 | DavQLStackObj intobj; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
813 | intobj.type = 0; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
814 | intobj.length = 0; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
815 | intobj.data.integer = intval; \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
816 | DAVQL_PUSH(intobj); \ |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
817 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
818 | #define DAVQL_POP() stack[--stpos] |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
819 | |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
820 | DavQLStackObj obj; |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
821 | int ret = 0; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
822 | for(size_t i=0;i<count;i++) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
823 | DavQLCmd cmd = cmds[i]; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
824 | switch(cmd.type) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
825 | case DAVQL_CMD_INT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
826 | //printf("int %lld\n", cmd.data.integer); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
827 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
828 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
829 | obj.data.integer = cmd.data.integer; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
830 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
831 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
832 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
833 | case DAVQL_CMD_STRING: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
834 | //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
|
835 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
836 | obj.length = cmd.data.string.length; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
837 | obj.data.string = cmd.data.string.ptr; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
838 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
839 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
840 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
841 | case DAVQL_CMD_TIMESTAMP: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
842 | //printf("timestamp %d\n", cmd.data.timestamp); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
843 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
844 | obj.length = 0; |
136
59058927b885
empty field results will no longer be added
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
845 | obj.data.integer = (int64_t)cmd.data.timestamp; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
846 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
847 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
848 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
849 | case DAVQL_CMD_RES_IDENTIFIER: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
850 | 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
|
851 | //printf("resprop %s\n", rid[cmd.data.resprop]); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
852 | switch(cmd.data.resprop) { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
853 | case DAVQL_RES_NAME: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
854 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
855 | obj.length = strlen(res->name); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
856 | obj.data.string = res->name; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
857 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
858 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
859 | case DAVQL_RES_PATH: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
860 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
861 | obj.length = strlen(res->path); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
862 | obj.data.string = res->path; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
863 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
864 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
865 | case DAVQL_RES_HREF: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
866 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
867 | obj.length = strlen(res->href); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
868 | obj.data.string = res->href; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
869 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
870 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
871 | case DAVQL_RES_CONTENTLENGTH: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
872 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
873 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
874 | obj.data.integer = res->contentlength; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
875 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
876 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
877 | case DAVQL_RES_CONTENTTYPE: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
878 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
879 | obj.length = strlen(res->contenttype); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
880 | obj.data.string = res->contenttype; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
881 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
882 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
883 | case DAVQL_RES_CREATIONDATE: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
884 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
885 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
886 | obj.data.integer = res->creationdate; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
887 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
888 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
889 | case DAVQL_RES_LASTMODIFIED: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
890 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
891 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
892 | obj.data.integer = res->lastmodified; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
893 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
894 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
895 | case DAVQL_RES_ISCOLLECTION: { |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
896 | obj.type = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
897 | obj.length = 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
898 | obj.data.integer = res->iscollection; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
899 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
900 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
901 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
902 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
903 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
904 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
905 | case DAVQL_CMD_PROP_IDENTIFIER: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
906 | //printf("property %s:%s\n", cmd.data.property.ns, cmd.data.property.name); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
907 | char *value = dav_get_property_ns(res, cmd.data.property.ns, cmd.data.property.name); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
908 | obj.type = 1; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
909 | obj.length = value ? strlen(value) : 0; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
910 | obj.data.string = value; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
911 | DAVQL_PUSH(obj); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
912 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
913 | } |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
914 | //case DAVQL_CMD_OP_UNARY_ADD: { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
915 | // printf("uadd\n"); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
916 | // break; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
917 | //} |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
918 | case DAVQL_CMD_OP_UNARY_SUB: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
919 | //printf("usub\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
920 | obj = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
921 | if(obj.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
922 | obj.data.integer = -obj.data.integer; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
923 | DAVQL_PUSH(obj); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
924 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
925 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
926 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
927 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
928 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
929 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
930 | case DAVQL_CMD_OP_UNARY_NEG: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
931 | //printf("uneg\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
932 | obj = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
933 | if(obj.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
934 | 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
|
935 | DAVQL_PUSH(obj); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
936 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
937 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
938 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
939 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
940 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
941 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
942 | case DAVQL_CMD_OP_BINARY_ADD: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
943 | //printf("add\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
944 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
945 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
946 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
947 | 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
|
948 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
949 | // TODO: string concat |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
950 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
951 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
952 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
953 | case DAVQL_CMD_OP_BINARY_SUB: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
954 | //printf("sub\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
955 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
956 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
957 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
958 | 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
|
959 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
960 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
961 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
962 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
963 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
964 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
965 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
966 | case DAVQL_CMD_OP_BINARY_MUL: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
967 | //printf("mul\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
968 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
969 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
970 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
971 | 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
|
972 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
973 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
974 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
975 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
976 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
977 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
978 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
979 | case DAVQL_CMD_OP_BINARY_DIV: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
980 | //printf("div\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
981 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
982 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
983 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
984 | 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
|
985 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
986 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
987 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
988 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
989 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
990 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
991 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
992 | case DAVQL_CMD_OP_BINARY_AND: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
993 | //printf("and\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
994 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
995 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
996 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
997 | 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
|
998 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
999 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1000 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1001 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1002 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1003 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1004 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1005 | case DAVQL_CMD_OP_BINARY_OR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1006 | //printf("or\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1007 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1008 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1009 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1010 | 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
|
1011 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1012 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1013 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1014 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1015 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1016 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1017 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1018 | case DAVQL_CMD_OP_BINARY_XOR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1019 | //printf("xor\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1020 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1021 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1022 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1023 | 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
|
1024 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1025 | // error |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1026 | ret = -1; |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1027 | i = count; // end loop |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1028 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1029 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1030 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1031 | case DAVQL_CMD_OP_LOGICAL_NOT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1032 | //printf("not\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1033 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1034 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1035 | case DAVQL_CMD_OP_LOGICAL_AND: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1036 | //printf("land\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1037 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1038 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1039 | 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
|
1040 | 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
|
1041 | DAVQL_PUSH_INT(v1 && v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1042 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1043 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1044 | case DAVQL_CMD_OP_LOGICAL_OR_L: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1045 | //printf("or_l %d\n", cmd.data.integer); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1046 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1047 | if((obj1.type == 0 && obj1.data.integer) || (obj1.type == 1 && obj1.data.string)) { |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1048 | DAVQL_PUSH_INT(1); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1049 | 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
|
1050 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1051 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1052 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1053 | case DAVQL_CMD_OP_LOGICAL_OR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1054 | //printf("or\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1055 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1056 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1057 | 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
|
1058 | 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
|
1059 | DAVQL_PUSH_INT(v1 || v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1060 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1061 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1062 | case DAVQL_CMD_OP_LOGICAL_XOR: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1063 | //printf("lxor\n"); |
134
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1064 | DavQLStackObj obj2 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1065 | DavQLStackObj obj1 = DAVQL_POP(); |
4bccc18820e8
implemented execution of field list expressions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
133
diff
changeset
|
1066 | 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
|
1067 | 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
|
1068 | DAVQL_PUSH_INT(!v1 != !v2); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1069 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1070 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1071 | case DAVQL_CMD_OP_EQ: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1072 | //printf("eq\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1073 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1074 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1075 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1076 | 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
|
1077 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1078 | // TODO: string compare |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1079 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1080 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1081 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1082 | case DAVQL_CMD_OP_NEQ: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1083 | //printf("neq\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1084 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1085 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1086 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1087 | 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
|
1088 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1089 | // TODO: string compare |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1090 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1091 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1092 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1093 | case DAVQL_CMD_OP_LT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1094 | //printf("lt\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1095 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1096 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1097 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1098 | 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
|
1099 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1100 | // TODO: string compare |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1101 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1102 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1103 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1104 | case DAVQL_CMD_OP_GT: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1105 | //printf("gt\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1106 | DavQLStackObj obj2 = DAVQL_POP(); |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1107 | DavQLStackObj obj1 = DAVQL_POP(); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1108 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1109 | 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
|
1110 | } else { |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1111 | // TODO: string compare |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1112 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1113 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1114 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1115 | case DAVQL_CMD_OP_LE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1116 | //printf("le\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1117 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1118 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1119 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1120 | 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
|
1121 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1122 | // TODO: string compare |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1123 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1124 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1125 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1126 | case DAVQL_CMD_OP_GE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1127 | //printf("ge\n"); |
133
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1128 | DavQLStackObj obj2 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1129 | DavQLStackObj obj1 = DAVQL_POP(); |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1130 | if(obj1.type == 0 && obj2.type == 0) { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1131 | 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
|
1132 | } else { |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1133 | // TODO: string compare |
8c37028f5024
implemented some davql integer operations
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
1134 | } |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1135 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1136 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1137 | case DAVQL_CMD_OP_LIKE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1138 | //printf("like\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1139 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1140 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1141 | case DAVQL_CMD_OP_UNLIKE: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1142 | //printf("unlike\n"); |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1143 | break; |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1144 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1145 | case DAVQL_CMD_CALL: { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
1146 | //printf("call %x\n", cmd.data.func); |
126
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 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1150 | } |
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1151 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1152 | if(stpos == 1) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1153 | *result = stack[0]; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1154 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1155 | ret = -1; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1156 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1157 | free(stack); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1158 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
127
diff
changeset
|
1159 | return ret; |
126
b156cae29e65
added expression executor prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
124
diff
changeset
|
1160 | } |