74 sstr_t cond = util_getsubstr_until_token(q, S("where"), &from_query); |
74 sstr_t cond = util_getsubstr_until_token(q, S("where"), &from_query); |
75 sstr_t with = util_getsubstr_until_token(cond, S("with"), &cond); |
75 sstr_t with = util_getsubstr_until_token(cond, S("with"), &cond); |
76 int depth = 1; |
76 int depth = 1; |
77 |
77 |
78 // insert variable values |
78 // insert variable values |
79 UcxBuffer *fbuf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); |
79 UcxBuffer *fbuf = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); |
80 int var = 0; |
80 int var = 0; |
81 for(int i=0;i<from_query.length;i++) { |
81 for(int i=0;i<from_query.length;i++) { |
82 char c = from_query.ptr[i]; |
82 char c = from_query.ptr[i]; |
83 if(c == '%') { |
83 if(c == '%') { |
84 if(var) { |
84 if(var) { |
135 } |
135 } |
136 } |
136 } |
137 |
137 |
138 DavGetQuery *getquery = malloc(sizeof(DavGetQuery)); |
138 DavGetQuery *getquery = malloc(sizeof(DavGetQuery)); |
139 getquery->properties = sstrdup(property_query); |
139 getquery->properties = sstrdup(property_query); |
140 getquery->from = sstrn(fbuf->space, fbuf->pos); |
140 getquery->from = sstrdup(sstrn(fbuf->space, fbuf->pos)); |
141 getquery->depth = depth; |
141 getquery->depth = depth; |
142 if(condition) { |
142 if(condition) { |
143 getquery->condition = condition; |
143 getquery->condition = condition; |
144 getquery->condlen = oplen; |
144 getquery->condlen = oplen; |
145 } else { |
145 } else { |
146 getquery->condition = NULL; |
146 getquery->condition = NULL; |
147 getquery->condlen = 0; |
147 getquery->condlen = 0; |
148 } |
148 } |
|
149 |
|
150 ucx_buffer_free(fbuf); |
149 return getquery; |
151 return getquery; |
150 } |
152 } |
151 |
153 |
152 void free_get_query(DavGetQuery *q) { |
154 void free_get_query(DavGetQuery *q) { |
153 free(q->from.ptr); |
155 free(q->from.ptr); |
154 free(q->properties.ptr); |
156 free(q->properties.ptr); |
|
157 if(q->condition) { |
|
158 free(q->condition); |
|
159 } |
155 free(q); |
160 free(q); |
156 } |
161 } |
157 |
162 |
158 int parse_path_query(sstr_t query, char **path, int *depth) { |
163 int parse_path_query(sstr_t query, char **path, int *depth) { |
159 if(query.length == 1) { |
164 if(query.length == 1) { |