db_backend.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_backend_h
#define __db_backend_h
struct db_backend_handle;
struct db_backend;
typedef struct db_backend_handle db_backend_handle_t;
typedef struct db_backend db_backend_t;
#include "db_configuration.h"
#include "db_result.h"
#include "db_object.h"
#include "db_join.h"
#include "db_clause.h"
#include "db_value.h"
typedef int (*db_backend_handle_initialize_t)(void* data);
typedef int (*db_backend_handle_shutdown_t)(void* data);
typedef int (*db_backend_handle_connect_t)(void* data, const db_configuration_list_t* configuration_list);
typedef int (*db_backend_handle_disconnect_t)(void* data);
typedef int (*db_backend_handle_create_t)(void* data, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set);
typedef db_result_list_t* (*db_backend_handle_read_t)(void* data, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list);
typedef int (*db_backend_handle_update_t)(void* data, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set, const db_clause_list_t* clause_list);
typedef int (*db_backend_handle_delete_t)(void* data, const db_object_t* object, const db_clause_list_t* clause_list);
typedef int (*db_backend_handle_count_t)(void* data, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list, size_t* count);
typedef void (*db_backend_handle_free_t)(void* data);
typedef int (*db_backend_handle_transaction_begin_t)(void* data);
typedef int (*db_backend_handle_transaction_commit_t)(void* data);
typedef int (*db_backend_handle_transaction_rollback_t)(void* data);
struct db_backend_handle {
void* data;
db_backend_handle_initialize_t initialize_function;
db_backend_handle_shutdown_t shutdown_function;
db_backend_handle_connect_t connect_function;
db_backend_handle_disconnect_t disconnect_function;
db_backend_handle_create_t create_function;
db_backend_handle_read_t read_function;
db_backend_handle_update_t update_function;
db_backend_handle_delete_t delete_function;
db_backend_handle_count_t count_function;
db_backend_handle_free_t free_function;
db_backend_handle_transaction_begin_t transaction_begin_function;
db_backend_handle_transaction_commit_t transaction_commit_function;
db_backend_handle_transaction_rollback_t transaction_rollback_function;
};
db_backend_handle_t* db_backend_handle_new(void);
void db_backend_handle_free(db_backend_handle_t* backend_handle);
int db_backend_handle_initialize(const db_backend_handle_t* backend_handle);
int db_backend_handle_connect(const db_backend_handle_t* backend_handle, const db_configuration_list_t* configuration_list);
int db_backend_handle_create(const db_backend_handle_t* backend_handle, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set);
db_result_list_t* db_backend_handle_read(const db_backend_handle_t* backend_handle, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list);
int db_backend_handle_update(const db_backend_handle_t* backend_handle, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set, const db_clause_list_t* clause_list);
int db_backend_handle_delete(const db_backend_handle_t* backend_handle, const db_object_t* object, const db_clause_list_t* clause_list);
int db_backend_handle_count(const db_backend_handle_t* backend_handle, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list, size_t* count);
int db_backend_handle_set_initialize(db_backend_handle_t* backend_handle, db_backend_handle_initialize_t initialize_function);
int db_backend_handle_set_shutdown(db_backend_handle_t* backend_handle, db_backend_handle_shutdown_t shutdown_function);
int db_backend_handle_set_connect(db_backend_handle_t* backend_handle, db_backend_handle_connect_t connect_function);
int db_backend_handle_set_disconnect(db_backend_handle_t* backend_handle, db_backend_handle_disconnect_t disconnect_function);
int db_backend_handle_set_create(db_backend_handle_t* backend_handle, db_backend_handle_create_t create_function);
int db_backend_handle_set_read(db_backend_handle_t* backend_handle, db_backend_handle_read_t read_function);
int db_backend_handle_set_update(db_backend_handle_t* backend_handle, db_backend_handle_update_t update_function);
int db_backend_handle_set_delete(db_backend_handle_t* backend_handle, db_backend_handle_delete_t delete_function);
int db_backend_handle_set_count(db_backend_handle_t* backend_handle, db_backend_handle_count_t count_function);
int db_backend_handle_set_free(db_backend_handle_t* backend_handle, db_backend_handle_free_t free_function);
int db_backend_handle_set_transaction_begin(db_backend_handle_t* backend_handle, db_backend_handle_transaction_begin_t transaction_begin_function);
int db_backend_handle_set_transaction_commit(db_backend_handle_t* backend_handle, db_backend_handle_transaction_commit_t transaction_commit_function);
int db_backend_handle_set_transaction_rollback(db_backend_handle_t* backend_handle, db_backend_handle_transaction_rollback_t transaction_rollback_function);
int db_backend_handle_set_data(db_backend_handle_t* backend_handle, void* data);
struct db_backend {
db_backend_t* next;
char* name;
db_backend_handle_t* handle;
};
db_backend_t* db_backend_new(void);
void db_backend_free(db_backend_t* backend);
const db_backend_handle_t* db_backend_handle(const db_backend_t* backend);
int db_backend_set_name(db_backend_t* backend, const char* name);
int db_backend_set_handle(db_backend_t* backend, db_backend_handle_t* handle);
int db_backend_initialize(const db_backend_t* backend);
int db_backend_connect(const db_backend_t* backend, const db_configuration_list_t* configuration_list);
int db_backend_create(const db_backend_t* backend, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set);
db_result_list_t* db_backend_read(const db_backend_t* backend, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list);
int db_backend_update(const db_backend_t* backend, const db_object_t* object, const db_object_field_list_t* object_field_list, const db_value_set_t* value_set, const db_clause_list_t* clause_list);
int db_backend_delete(const db_backend_t* backend, const db_object_t* object, const db_clause_list_t* clause_list);
int db_backend_count(const db_backend_t* backend, const db_object_t* object, const db_join_list_t* join_list, const db_clause_list_t* clause_list, size_t* count);
db_backend_t* db_backend_factory_get_backend(const char* name);
#endif
db_backend_handle::connect_function
db_backend_handle_connect_t connect_function
Definition: db_backend.h:173
db_configuration_list
Definition: db_configuration.h:93
db_value.h
db_backend_set_handle
int db_backend_set_handle(db_backend_t *backend, db_backend_handle_t *handle)
Definition: db_backend.c:348
db_backend_handle_transaction_rollback_t
int(* db_backend_handle_transaction_rollback_t)(void *data)
Definition: db_backend.h:163
db_backend_handle_initialize
int db_backend_handle_initialize(const db_backend_handle_t *backend_handle)
Definition: db_backend.c:68
db_backend_handle_set_connect
int db_backend_handle_set_connect(db_backend_handle_t *backend_handle, db_backend_handle_connect_t connect_function)
Definition: db_backend.c:196
db_backend_handle
const db_backend_handle_t * db_backend_handle(const db_backend_t *backend)
db_backend_handle
Definition: db_backend.h:169
db_backend_handle_set_shutdown
int db_backend_handle_set_shutdown(db_backend_handle_t *backend_handle, db_backend_handle_shutdown_t shutdown_function)
Definition: db_backend.c:187
db_object
Definition: db_object.h:201
db_backend_handle_set_read
int db_backend_handle_set_read(db_backend_handle_t *backend_handle, db_backend_handle_read_t read_function)
Definition: db_backend.c:223
db_backend::name
char * name
Definition: db_backend.h:386
db_clause_list
Definition: db_clause.h:226
db_backend_delete
int db_backend_delete(const db_backend_t *backend, const db_object_t *object, const db_clause_list_t *clause_list)
Definition: db_backend.c:439
db_backend_handle_free
void db_backend_handle_free(db_backend_handle_t *backend_handle)
Definition: db_backend.c:56
db_backend_handle_set_transaction_commit
int db_backend_handle_set_transaction_commit(db_backend_handle_t *backend_handle, db_backend_handle_transaction_commit_t transaction_commit_function)
Definition: db_backend.c:277
db_backend_handle::transaction_begin_function
db_backend_handle_transaction_begin_t transaction_begin_function
Definition: db_backend.h:181
db_object_field_list
Definition: db_object.h:142
db_result.h
db_backend_handle::initialize_function
db_backend_handle_initialize_t initialize_function
Definition: db_backend.h:171
db_backend_handle_create
int db_backend_handle_create(const db_backend_handle_t *backend_handle, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set)
Definition: db_backend.c:93
db_backend_free
void db_backend_free(db_backend_t *backend)
Definition: db_backend.c:318
db_backend_handle_set_create
int db_backend_handle_set_create(db_backend_handle_t *backend_handle, db_backend_handle_create_t create_function)
Definition: db_backend.c:214
db_backend_handle_connect
int db_backend_handle_connect(const db_backend_handle_t *backend_handle, const db_configuration_list_t *configuration_list)
Definition: db_backend.c:79
db_backend_handle_new
db_backend_handle_t * db_backend_handle_new(void)
Definition: db_backend.c:49
db_value_set
Definition: db_value.h:281
db_result_list
Definition: db_result.h:114
db_join_list
Definition: db_join.h:94
db_backend_handle_transaction_begin_t
int(* db_backend_handle_transaction_begin_t)(void *data)
Definition: db_backend.h:147
db_backend_handle::transaction_rollback_function
db_backend_handle_transaction_rollback_t transaction_rollback_function
Definition: db_backend.h:183
db_backend
Definition: db_backend.h:384
db_backend_handle_count_t
int(* db_backend_handle_count_t)(void *data, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list, size_t *count)
Definition: db_backend.h:133
db_backend_handle_read_t
db_result_list_t *(* db_backend_handle_read_t)(void *data, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list)
Definition: db_backend.h:99
db_backend_handle_set_update
int db_backend_handle_set_update(db_backend_handle_t *backend_handle, db_backend_handle_update_t update_function)
Definition: db_backend.c:232
db_backend_handle_set_data
int db_backend_handle_set_data(db_backend_handle_t *backend_handle, void *data)
Definition: db_backend.c:295
db_backend_connect
int db_backend_connect(const db_backend_t *backend, const db_configuration_list_t *configuration_list)
Definition: db_backend.c:371
db_backend_set_name
int db_backend_set_name(db_backend_t *backend, const char *name)
Definition: db_backend.c:330
db_backend_handle_update
int db_backend_handle_update(const db_backend_handle_t *backend_handle, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set, const db_clause_list_t *clause_list)
Definition: db_backend.c:127
db_backend_handle_delete
int db_backend_handle_delete(const db_backend_handle_t *backend_handle, const db_object_t *object, const db_clause_list_t *clause_list)
Definition: db_backend.c:147
db_configuration.h
db_backend_handle_read
db_result_list_t * db_backend_handle_read(const db_backend_handle_t *backend_handle, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list)
Definition: db_backend.c:113
db_backend_handle_set_initialize
int db_backend_handle_set_initialize(db_backend_handle_t *backend_handle, db_backend_handle_initialize_t initialize_function)
Definition: db_backend.c:178
db_backend_handle_initialize_t
int(* db_backend_handle_initialize_t)(void *data)
Definition: db_backend.h:51
db_backend_factory_get_backend
db_backend_t * db_backend_factory_get_backend(const char *name)
Definition: db_backend.c:472
db_backend_handle_transaction_commit_t
int(* db_backend_handle_transaction_commit_t)(void *data)
Definition: db_backend.h:155
db_backend_handle::update_function
db_backend_handle_update_t update_function
Definition: db_backend.h:177
db_backend_new
db_backend_t * db_backend_new(void)
Definition: db_backend.c:311
db_backend_handle::shutdown_function
db_backend_handle_shutdown_t shutdown_function
Definition: db_backend.h:172
db_backend_handle_free_t
void(* db_backend_handle_free_t)(void *data)
Definition: db_backend.h:139
db_backend_handle_set_transaction_rollback
int db_backend_handle_set_transaction_rollback(db_backend_handle_t *backend_handle, db_backend_handle_transaction_rollback_t transaction_rollback_function)
Definition: db_backend.c:286
db_backend_handle_update_t
int(* db_backend_handle_update_t)(void *data, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set, const db_clause_list_t *clause_list)
Definition: db_backend.h:111
db_backend_handle_set_transaction_begin
int db_backend_handle_set_transaction_begin(db_backend_handle_t *backend_handle, db_backend_handle_transaction_begin_t transaction_begin_function)
Definition: db_backend.c:268
db_backend_create
int db_backend_create(const db_backend_t *backend, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set)
Definition: db_backend.c:385
db_backend_handle::disconnect_function
db_backend_handle_disconnect_t disconnect_function
Definition: db_backend.h:174
db_clause.h
db_backend_handle_delete_t
int(* db_backend_handle_delete_t)(void *data, const db_object_t *object, const db_clause_list_t *clause_list)
Definition: db_backend.h:121
db_backend::next
db_backend_t * next
Definition: db_backend.h:385
db_join.h
db_backend_handle::transaction_commit_function
db_backend_handle_transaction_commit_t transaction_commit_function
Definition: db_backend.h:182
db_object.h
db_backend_read
db_result_list_t * db_backend_read(const db_backend_t *backend, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list)
Definition: db_backend.c:405
db_backend_handle_disconnect_t
int(* db_backend_handle_disconnect_t)(void *data)
Definition: db_backend.h:76
db_backend_handle_create_t
int(* db_backend_handle_create_t)(void *data, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set)
Definition: db_backend.h:87
db_backend_handle::count_function
db_backend_handle_count_t count_function
Definition: db_backend.h:179
db_backend_handle::data
void * data
Definition: db_backend.h:170
db_backend::handle
db_backend_handle_t * handle
Definition: db_backend.h:387
db_backend_handle_set_delete
int db_backend_handle_set_delete(db_backend_handle_t *backend_handle, db_backend_handle_delete_t delete_function)
Definition: db_backend.c:241
db_backend_update
int db_backend_update(const db_backend_t *backend, const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set, const db_clause_list_t *clause_list)
Definition: db_backend.c:419
db_backend_count
int db_backend_count(const db_backend_t *backend, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list, size_t *count)
Definition: db_backend.c:453
db_backend_handle_shutdown_t
int(* db_backend_handle_shutdown_t)(void *data)
Definition: db_backend.h:59
db_backend_handle_set_disconnect
int db_backend_handle_set_disconnect(db_backend_handle_t *backend_handle, db_backend_handle_disconnect_t disconnect_function)
Definition: db_backend.c:205
db_backend_initialize
int db_backend_initialize(const db_backend_t *backend)
Definition: db_backend.c:360
db_backend_handle::create_function
db_backend_handle_create_t create_function
Definition: db_backend.h:175
db_backend_handle_set_free
int db_backend_handle_set_free(db_backend_handle_t *backend_handle, db_backend_handle_free_t free_function)
Definition: db_backend.c:259
db_backend_handle_connect_t
int(* db_backend_handle_connect_t)(void *data, const db_configuration_list_t *configuration_list)
Definition: db_backend.h:68
db_backend_handle_set_count
int db_backend_handle_set_count(db_backend_handle_t *backend_handle, db_backend_handle_count_t count_function)
Definition: db_backend.c:250
db_backend_handle_count
int db_backend_handle_count(const db_backend_handle_t *backend_handle, const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list, size_t *count)
Definition: db_backend.c:161
db_backend_handle::read_function
db_backend_handle_read_t read_function
Definition: db_backend.h:176
db_backend_handle::delete_function
db_backend_handle_delete_t delete_function
Definition: db_backend.h:178
db_backend_handle::free_function
db_backend_handle_free_t free_function
Definition: db_backend.h:180