libidav/davqlexec.h

changeset 124
41939c8f3f9c
parent 123
806c4dccf2ae
child 126
b156cae29e65
equal deleted inserted replaced
123:806c4dccf2ae 124:41939c8f3f9c
36 36
37 #ifdef __cplusplus 37 #ifdef __cplusplus
38 extern "C" { 38 extern "C" {
39 #endif 39 #endif
40 40
41 typedef struct DavQLResult DavQLResult; 41 typedef struct DavQLCmd DavQLCmd;
42 typedef struct DavQLStackObj DavQLStackObj;
43
44 typedef void*(*davql_func)(); // TODO: interface?
42 45
43 typedef enum { 46 typedef enum {
44 DAVQL_OK = 0, 47 DAVQL_OK = 0,
45 DAVQL_UNSUPPORTED_FORMATCHAR, 48 DAVQL_UNSUPPORTED_FORMATCHAR,
46 DAVQL_UNKNOWN_FORMATCHAR 49 DAVQL_UNKNOWN_FORMATCHAR
47 } davqlerror_t; 50 } davqlerror_t;
48 51
49 struct DavQLResult { 52 typedef enum {
50 DavResource *result; 53 DAVQL_CMD_INT = 0,
51 int status; 54 DAVQL_CMD_STRING,
55 DAVQL_CMD_TIMESTAMP,
56 DAVQL_CMD_RES_IDENTIFIER,
57 DAVQL_CMD_PROP_IDENTIFIER,
58 DAVQL_CMD_OP_UNARY_ADD,
59 DAVQL_CMD_OP_UNARY_SUB,
60 DAVQL_CMD_OP_UNARY_NEG,
61 DAVQL_CMD_OP_BINARY_ADD,
62 DAVQL_CMD_OP_BINARY_SUB,
63 DAVQL_CMD_OP_BINARY_MUL,
64 DAVQL_CMD_OP_BINARY_DIV,
65 DAVQL_CMD_OP_BINARY_AND,
66 DAVQL_CMD_OP_BINARY_OR,
67 DAVQL_CMD_OP_BINARY_XOR,
68 DAVQL_CMD_OP_LOGICAL_NOT,
69 DAVQL_CMD_OP_LOGICAL_AND,
70 DAVQL_CMD_OP_LOGICAL_OR_L,
71 DAVQL_CMD_OP_LOGICAL_OR,
72 DAVQL_CMD_OP_LOGICAL_XOR,
73 DAVQL_CMD_OP_EQ,
74 DAVQL_CMD_OP_NEQ,
75 DAVQL_CMD_OP_LT,
76 DAVQL_CMD_OP_GT,
77 DAVQL_CMD_OP_LE,
78 DAVQL_CMD_OP_GE,
79 DAVQL_CMD_OP_LIKE,
80 DAVQL_CMD_OP_UNLIKE,
81 DAVQL_CMD_CALL
82 } davqlcmdtype_t;
83
84 typedef enum {
85 DAVQL_RES_NAME = 0,
86 DAVQL_RES_PATH,
87 DAVQL_RES_HREF,
88 DAVQL_RES_CONTENTLENGTH,
89 DAVQL_RES_CONTENTTYPE,
90 DAVQL_RES_CREATIONDATE,
91 DAVQL_RES_LASTMODIFIED,
92 DAVQL_RES_ISCOLLECTION
93 } davqlresprop_t;
94
95 struct DavQLCmd {
96 davqlcmdtype_t type;
97 union DavQLCmdData {
98 int64_t integer;
99 sstr_t string;
100 time_t timestamp;
101 davqlresprop_t resprop;
102 DavPropName property;
103 davql_func func;
104 } data;
105 };
106
107 struct DavQLStackObj {
108 int32_t type; // 0: int, 1: string
109 uint32_t length;
110 union DavQLStackData {
111 int64_t integer;
112 char *string;
113 } data;
52 }; 114 };
53 115
54 DavQLResult* dav_statement_exec(DavSession *sn, DavQLStatement *st, ...); 116 DavQLResult* dav_statement_exec(DavSession *sn, DavQLStatement *st, ...);
55 DavQLResult* dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap); 117 DavQLResult* dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap);
56 118
57 UcxBuffer* dav_path_string(sstr_t src, va_list ap, davqlerror_t *error); 119 UcxBuffer* dav_path_string(sstr_t src, va_list ap, davqlerror_t *error);
120 sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list ap, davqlerror_t *error);
58 121
59 void dav_exec_get(DavSession *sn, DavQLStatement *st, char* path, va_list ap); 122 void dav_exec_get(DavSession *sn, DavQLStatement *st, char* path, va_list ap);
60 123
61 UcxBuffer* dav_compile_lexpr(DavQLExpression *lexpr); 124 UcxBuffer* dav_compile_expr(UcxAllocator *a, DavQLExpression *lexpr, va_list ap);
62 125
63 126
64 127 void print_bytecode(UcxBuffer *bcode);
65 128
66 #ifdef __cplusplus 129 #ifdef __cplusplus
67 } 130 }
68 #endif 131 #endif
69 132

mercurial