db_clause.h
Go to the documentation of this file.
/*
* Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com>
* Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
* Copyright (c) 2014 OpenDNSSEC AB (svb)
* 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 AUTHOR ``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 AUTHOR 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 __db_clause_h
#define __db_clause_h
typedef enum {
DB_CLAUSE_UNKNOWN,
DB_CLAUSE_EQUAL,
DB_CLAUSE_NOT_EQUAL,
DB_CLAUSE_LESS_THEN,
DB_CLAUSE_LESS_OR_EQUAL,
DB_CLAUSE_GREATER_OR_EQUAL,
DB_CLAUSE_GREATER_THEN,
DB_CLAUSE_IS_NULL,
DB_CLAUSE_IS_NOT_NULL,
DB_CLAUSE_NESTED
} db_clause_type_t;
#define DB_CLAUSE_EQ DB_CLAUSE_EQUAL
#define DB_CLAUSE_NE DB_CLAUSE_NOT_EQUAL
#define DB_CLAUSE_LT DB_CLAUSE_LESS_THEN
#define DB_CLAUSE_LE DB_CLAUSE_LESS_OR_EQUAL
#define DB_CLAUSE_GE DB_CLAUSE_GREATER_OR_EQUAL
#define DB_CLAUSE_GT DB_CLAUSE_GREATER_THEN
typedef enum {
DB_CLAUSE_OPERATOR_UNKNOWN,
DB_CLAUSE_OPERATOR_AND,
DB_CLAUSE_OPERATOR_OR
} db_clause_operator_t;
#define DB_CLAUSE_OP_AND DB_CLAUSE_OPERATOR_AND
#define DB_CLAUSE_OP_OR DB_CLAUSE_OPERATOR_OR
struct db_clause;
struct db_clause_list;
typedef struct db_clause db_clause_t;
typedef struct db_clause_list db_clause_list_t;
#include "db_value.h"
struct db_clause {
db_clause_t* next;
char* table;
char* field;
db_clause_type_t type;
db_value_t value;
db_clause_operator_t clause_operator;
db_clause_list_t* clause_list;
};
extern db_clause_t* db_clause_new(void);
extern void db_clause_free(db_clause_t* clause);
extern const char* db_clause_field(const db_clause_t* clause);
extern db_clause_type_t db_clause_type(const db_clause_t* clause);
extern const db_value_t* db_clause_value(const db_clause_t* clause);
extern db_clause_operator_t db_clause_operator(const db_clause_t* clause);
extern const db_clause_list_t* db_clause_list(const db_clause_t* clause);
extern int db_clause_set_field(db_clause_t* clause, const char* field);
extern int db_clause_set_type(db_clause_t* clause, db_clause_type_t type);
extern int db_clause_set_operator(db_clause_t* clause, db_clause_operator_t clause_operator);
extern int db_clause_not_empty(const db_clause_t* clause);
extern const db_clause_t* db_clause_next(const db_clause_t* clause);
extern db_value_t* db_clause_get_value(db_clause_t* clause);
struct db_clause_list {
db_clause_t* begin;
db_clause_t* end;
};
extern db_clause_list_t* db_clause_list_new(void);
extern void db_clause_list_free(db_clause_list_t* clause_list);
extern int db_clause_list_add(db_clause_list_t* clause_list, db_clause_t* clause);
extern const db_clause_t* db_clause_list_begin(const db_clause_list_t* clause_list);
#endif
db_clause_operator
db_clause_operator_t db_clause_operator(const db_clause_t *clause)
Definition db_clause.c:93
db_clause_value
const db_value_t * db_clause_value(const db_clause_t *clause)
Definition db_clause.c:85
db_clause_free
void db_clause_free(db_clause_t *clause)
Definition db_clause.c:56
db_clause_type
db_clause_type_t db_clause_type(const db_clause_t *clause)
Definition db_clause.c:77
db_clause_list_new
db_clause_list_t * db_clause_list_new(void)
Definition db_clause.c:202
db_clause_new
db_clause_t * db_clause_new(void)
Definition db_clause.c:43
db_clause_next
const db_clause_t * db_clause_next(const db_clause_t *clause)
Definition db_clause.c:179
db_clause_operator_t
db_clause_operator_t
Definition db_clause.h:89
DB_CLAUSE_OPERATOR_UNKNOWN
@ DB_CLAUSE_OPERATOR_UNKNOWN
Definition db_clause.h:93
DB_CLAUSE_OPERATOR_AND
@ DB_CLAUSE_OPERATOR_AND
Definition db_clause.h:97
DB_CLAUSE_OPERATOR_OR
@ DB_CLAUSE_OPERATOR_OR
Definition db_clause.h:101
db_clause_get_value
db_value_t * db_clause_get_value(db_clause_t *clause)
Definition db_clause.c:187
db_clause_field
const char * db_clause_field(const db_clause_t *clause)
Definition db_clause.c:69
db_clause_list_add
int db_clause_list_add(db_clause_list_t *clause_list, db_clause_t *clause)
Definition db_clause.c:226
db_clause_list_free
void db_clause_list_free(db_clause_list_t *clause_list)
Definition db_clause.c:209
db_clause_type_t
db_clause_type_t
Definition db_clause.h:36
DB_CLAUSE_NESTED
@ DB_CLAUSE_NESTED
Definition db_clause.h:76
DB_CLAUSE_GREATER_THEN
@ DB_CLAUSE_GREATER_THEN
Definition db_clause.h:64
DB_CLAUSE_NOT_EQUAL
@ DB_CLAUSE_NOT_EQUAL
Definition db_clause.h:48
DB_CLAUSE_IS_NOT_NULL
@ DB_CLAUSE_IS_NOT_NULL
Definition db_clause.h:72
DB_CLAUSE_UNKNOWN
@ DB_CLAUSE_UNKNOWN
Definition db_clause.h:40
DB_CLAUSE_GREATER_OR_EQUAL
@ DB_CLAUSE_GREATER_OR_EQUAL
Definition db_clause.h:60
DB_CLAUSE_IS_NULL
@ DB_CLAUSE_IS_NULL
Definition db_clause.h:68
DB_CLAUSE_EQUAL
@ DB_CLAUSE_EQUAL
Definition db_clause.h:44
DB_CLAUSE_LESS_OR_EQUAL
@ DB_CLAUSE_LESS_OR_EQUAL
Definition db_clause.h:56
DB_CLAUSE_LESS_THEN
@ DB_CLAUSE_LESS_THEN
Definition db_clause.h:52
db_clause_set_operator
int db_clause_set_operator(db_clause_t *clause, db_clause_operator_t clause_operator)
Definition db_clause.c:142
db_clause_set_field
int db_clause_set_field(db_clause_t *clause, const char *field)
Definition db_clause.c:109
db_clause_list_begin
const db_clause_t * db_clause_list_begin(const db_clause_list_t *clause_list)
Definition db_clause.c:255
db_clause_not_empty
int db_clause_not_empty(const db_clause_t *clause)
Definition db_clause.c:154
db_clause_set_type
int db_clause_set_type(db_clause_t *clause, db_clause_type_t type)
Definition db_clause.c:130
db_value.h
db_clause_list
Definition db_clause.h:226
db_clause_list::begin
db_clause_t * begin
Definition db_clause.h:227
db_clause_list::end
db_clause_t * end
Definition db_clause.h:228
db_clause
Definition db_clause.h:118
db_clause::value
db_value_t value
Definition db_clause.h:123
db_clause::next
db_clause_t * next
Definition db_clause.h:119
db_clause::type
db_clause_type_t type
Definition db_clause.h:122
db_clause::clause_operator
db_clause_operator_t clause_operator
Definition db_clause.h:124
db_clause::clause_list
db_clause_list_t * clause_list
Definition db_clause.h:125
db_clause::field
char * field
Definition db_clause.h:121
db_clause::table
char * table
Definition db_clause.h:120
db_value
Definition db_value.h:48