libidav/davqlexec.h

Sat, 30 May 2015 14:14:36 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 30 May 2015 14:14:36 +0200
changeset 125
5e2576b08680
parent 124
41939c8f3f9c
child 126
b156cae29e65
permissions
-rw-r--r--

fixed: comparison operator info has been incorrectly written to type field

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2015 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef DAVQLEXEC_H
#define	DAVQLEXEC_H

#include <stdarg.h>
#include "davqlparser.h"
#include "webdav.h"

#include <ucx/buffer.h>

#ifdef	__cplusplus
extern "C" {
#endif

typedef struct DavQLCmd      DavQLCmd;
typedef struct DavQLStackObj DavQLStackObj;

typedef void*(*davql_func)(); // TODO: interface?

typedef enum {
    DAVQL_OK = 0,
    DAVQL_UNSUPPORTED_FORMATCHAR,
    DAVQL_UNKNOWN_FORMATCHAR
} 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_ADD,
    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;
        sstr_t         string;
        time_t         timestamp;
        davqlresprop_t resprop;
        DavPropName    property;
        davql_func     func;
    } data;
};

struct DavQLStackObj {
    int32_t  type; // 0: int, 1: string
    uint32_t length;
    union DavQLStackData {
        int64_t integer;
        char    *string;
    } data;
};
    
DavQLResult* dav_statement_exec(DavSession *sn, DavQLStatement *st, ...);
DavQLResult* dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap);

UcxBuffer* dav_path_string(sstr_t src, va_list ap, davqlerror_t *error);
sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list ap, davqlerror_t *error);

void dav_exec_get(DavSession *sn, DavQLStatement *st, char* path, va_list ap);

UcxBuffer* dav_compile_expr(UcxAllocator *a, DavQLExpression *lexpr, va_list ap);


void print_bytecode(UcxBuffer *bcode);

#ifdef	__cplusplus
}
#endif

#endif	/* DAVQLEXEC_H */

mercurial