#ifndef DAVQLEXEC_H
#define DAVQLEXEC_H
#include <stdarg.h>
#include "davqlparser.h"
#include "webdav.h"
#include <cx/buffer.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DavQLCmd DavQLCmd;
typedef struct DavQLStackObj DavQLStackObj;
typedef struct DavQLRes DavQLRes;
typedef struct DavQLArg DavQLArg;
typedef struct DavQLArgList DavQLArgList;
typedef void*(*davql_func)();
struct DavQLArg {
int type;
union DavQLArgValue{
int d;
unsigned int u;
char *s;
time_t t;
} value;
DavQLArg *next;
};
struct DavQLArgList {
DavQLArg *first;
DavQLArg *current;
};
typedef enum {
DAVQL_OK =
0,
DAVQL_UNSUPPORTED_FORMATCHAR,
DAVQL_UNKNOWN_FORMATCHAR,
DAVQL_OOM
}
davqlerror_t;
typedef enum {
DAVQL_CMD_INT =
0,
DAVQL_CMD_STRING,
DAVQL_CMD_TIMESTAMP,
DAVQL_CMD_RES_IDENTIFIER,
DAVQL_CMD_PROP_IDENTIFIER,
DAVQL_CMD_OP_UNARY_SUB,
DAVQL_CMD_OP_UNARY_NEG,
DAVQL_CMD_OP_BINARY_ADD,
DAVQL_CMD_OP_BINARY_SUB,
DAVQL_CMD_OP_BINARY_MUL,
DAVQL_CMD_OP_BINARY_DIV,
DAVQL_CMD_OP_BINARY_AND,
DAVQL_CMD_OP_BINARY_OR,
DAVQL_CMD_OP_BINARY_XOR,
DAVQL_CMD_OP_LOGICAL_NOT,
DAVQL_CMD_OP_LOGICAL_AND,
DAVQL_CMD_OP_LOGICAL_OR_L,
DAVQL_CMD_OP_LOGICAL_OR,
DAVQL_CMD_OP_LOGICAL_XOR,
DAVQL_CMD_OP_EQ,
DAVQL_CMD_OP_NEQ,
DAVQL_CMD_OP_LT,
DAVQL_CMD_OP_GT,
DAVQL_CMD_OP_LE,
DAVQL_CMD_OP_GE,
DAVQL_CMD_OP_LIKE,
DAVQL_CMD_OP_UNLIKE,
DAVQL_CMD_CALL
}
davqlcmdtype_t;
typedef enum {
DAVQL_RES_NAME =
0,
DAVQL_RES_PATH,
DAVQL_RES_HREF,
DAVQL_RES_CONTENTLENGTH,
DAVQL_RES_CONTENTTYPE,
DAVQL_RES_CREATIONDATE,
DAVQL_RES_LASTMODIFIED,
DAVQL_RES_ISCOLLECTION
}
davqlresprop_t;
struct DavQLCmd {
davqlcmdtype_t type;
union DavQLCmdData {
int64_t integer;
cxmutstr string;
time_t timestamp;
davqlresprop_t resprop;
DavPropName property;
davql_func func;
} data;
};
struct DavQLStackObj {
int32_t type;
uint32_t length;
union DavQLStackData {
int64_t integer;
char *string;
DavXmlNode *node;
} data;
};
struct DavQLRes {
DavResource *resource;
int depth;
};
typedef struct DavCompiledField {
char *ns;
char *name;
CxBuffer *code;
} DavCompiledField;
typedef struct DavOrderCriterion {
int type;
union DavQLColumn {
davqlresprop_t resprop;
CxHashKey property;
} column;
_Bool descending;
} DavOrderCriterion;
DavQLArgList* dav_ql_get_args(DavQLStatement *st, va_list ap);
void dav_ql_free_arglist(DavQLArgList *args);
int dav_ql_getarg_int(DavQLArgList *args);
unsigned int dav_ql_getarg_uint(DavQLArgList *args);
char* dav_ql_getarg_str(DavQLArgList *args);
time_t dav_ql_getarg_time(DavQLArgList *args);
DavResult dav_statement_exec(DavSession *sn, DavQLStatement *st, ...);
DavResult dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap);
CxBuffer* dav_path_string(cxmutstr src, DavQLArgList *args,
davqlerror_t *error);
cxmutstr dav_format_string(
const CxAllocator *a, cxstring fstr, DavQLArgList *ap,
davqlerror_t *error);
DavResult dav_exec_select(DavSession *sn, DavQLStatement *st, va_list ap);
int dav_identifier2resprop(cxstring src,
davqlresprop_t *prop);
CxBuffer* dav_compile_expr(DavContext *ctx,
const CxAllocator *a, DavQLExpression *lexpr, DavQLArgList *ap);
int dav_exec_expr(CxBuffer *bcode, DavResource *res, DavQLStackObj *result);
#ifdef __cplusplus
}
#endif
#endif