dav/davql.h

changeset 27
e584c351b402
parent 17
11dffb40cd91
--- a/dav/davql.h	Tue Aug 20 11:34:44 2013 +0200
+++ b/dav/davql.h	Wed Aug 21 13:08:22 2013 +0200
@@ -26,10 +26,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "webdav.h"
+
 #ifndef DAVQL_H
 #define	DAVQL_H
 
 #include <ucx/string.h>
+#include <ucx/list.h>
+#include <inttypes.h>
 #include <stdarg.h>
 
 #ifdef	__cplusplus
@@ -41,6 +45,19 @@
     DAV_QUERY_GET
 };
 typedef enum DavQueryType DavQueryType;
+
+#define DAVQOP_OPERATOR    0
+#define DAVQOP_STRING      1
+#define DAVQOP_INTEGER     2
+#define DAVQOP_TIME        3
+#define DAVQOP_PROPERTY    4
+#define DAVQOP_RESPROP     5
+
+typedef struct {
+    int      type;
+    void     *val;
+    int64_t intval;
+} DavQOp;
     
 typedef struct {
     DavQueryType command;
@@ -50,7 +67,8 @@
 typedef struct {
     sstr_t properties;
     sstr_t from;
-    // TODO: condition
+    DavQOp *condition;
+    size_t condlen;
 } DavGetQuery;
     
 DavQuery dav_ql_parse(char *query, va_list ap);
@@ -59,6 +77,15 @@
 
 int parse_path_query(sstr_t query, char **path, int *depth);
 
+int dav_parse_condition(UcxList **ops, sstr_t cond, va_list ap);
+sstr_t condition_parser_next_token(sstr_t *str);
+int condition_operator_type(sstr_t token, int64_t *type);
+
+int condition_eval(DavResource *res, DavQOp *cond, size_t len);
+DavQOp compare_intint(int op, int64_t v1, int64_t v2);
+DavQOp compare_strint(int op, DavQOp v1, DavQOp v2);
+DavQOp compare_intstr(int op, DavQOp v1, DavQOp v2);
+DavQOp compare_strstr(int op, DavQOp v1, DavQOp v2);
 
 #ifdef	__cplusplus
 }

mercurial