Loading...
Searching...
No Matches
hoel.h
Go to the documentation of this file.
#ifndef __HOEL_H__
#define __HOEL_H__
#ifdef __cplusplus
extern "C"
{
#endif
#include "hoel-cfg.h"
#include <jansson.h>
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
#include <time.h>
#include <pthread.h>
#include <yder.h>
#include <orcania.h>
#define HOEL_DB_TYPE_SQLITE 0
#define HOEL_DB_TYPE_MARIADB 1
#define HOEL_DB_TYPE_PGSQL 2
#define HOEL_COL_TYPE_INT 0
#define HOEL_COL_TYPE_DOUBLE 1
#define HOEL_COL_TYPE_TEXT 2
#define HOEL_COL_TYPE_DATE 3
#define HOEL_COL_TYPE_BLOB 4
#define HOEL_COL_TYPE_BOOL 5
#define HOEL_COL_TYPE_NULL 5
#define H_OK 0 /* No error */
#define H_ERROR 1 /* Generic error */
#define H_ERROR_PARAMS 2 /* Error in input parameters */
#define H_ERROR_CONNECTION 3 /* Error in database connection */
#define H_ERROR_QUERY 4 /* Error executing query */
#define H_ERROR_MEMORY 99 /* Error allocating memory */
#define H_OPTION_NONE 0x0000 /* Nothing whatsoever */
#define H_OPTION_SELECT 0x0001 /* Execute a SELECT statement */
#define H_OPTION_EXEC 0x0010 /* Execute an INSERT, UPDATE or DELETE statement */
struct _h_connection {
int type;
void * connection;
};
struct _h_type_int {
long long int value;
};
struct _h_type_double {
double value;
};
struct _h_type_datetime {
struct tm value;
};
struct _h_type_text {
size_t length;
char * value;
};
struct _h_type_blob {
size_t length;
void * value;
};
struct _h_data {
int type;
void * t_data;
};
struct _h_result {
unsigned int nb_rows;
unsigned int nb_columns;
struct _h_data ** data;
};
int h_close_db(struct _h_connection * conn);
void h_free(void * data);
char * h_escape_string(const struct _h_connection * conn, const char * unsafe);
char * h_escape_string_with_quotes(const struct _h_connection * conn, const char * unsafe);
int h_execute_query(const struct _h_connection * conn, const char * query, struct _h_result * result, int options);
int h_query_insert(const struct _h_connection * conn, const char * query);
struct _h_data * h_query_last_insert_id(const struct _h_connection * conn);
int h_query_update(const struct _h_connection * conn, const char * query);
int h_query_delete(const struct _h_connection * conn, const char * query);
int h_query_select(const struct _h_connection * conn, const char * query, struct _h_result * result);
int h_execute_query_json(const struct _h_connection * conn, const char * query, json_t ** j_result);
int h_query_select_json(const struct _h_connection * conn, const char * query, json_t ** j_result);
int h_select(const struct _h_connection * conn, const json_t * j_query, json_t ** j_result, char ** generated_query);
int h_insert(const struct _h_connection * conn, const json_t * j_query, char ** generated_query);
json_t * h_last_insert_id(const struct _h_connection * conn);
int h_update(const struct _h_connection * conn, const json_t * j_query, char ** generated_query);
int h_delete(const struct _h_connection * conn, const json_t * j_query, char ** generated_query);
char * h_build_where_clause(const struct _h_connection * conn, const char * pattern, ...);
int h_clean_result(struct _h_result * result);
int h_clean_data(struct _h_data * data);
int h_clean_data_full(struct _h_data * data);
int h_clean_connection(struct _h_connection * conn);
struct _h_connection * h_connect_sqlite(const char * db_path);
void h_close_sqlite(struct _h_connection * conn);
char * h_escape_string_sqlite(const struct _h_connection * conn, const char * unsafe);
char * h_escape_string_with_quotes_sqlite(const struct _h_connection * conn, const char * unsafe);
long long int h_last_insert_id_sqlite(const struct _h_connection * conn);
int h_exec_query_sqlite(const struct _h_connection * conn, const char * query);
int h_execute_query_sqlite(const struct _h_connection * conn, const char * query);
int h_execute_query_json_sqlite(const struct _h_connection * conn, const char * query, json_t ** j_result);
int h_select_query_sqlite(const struct _h_connection * conn, const char * query, struct _h_result * result);
struct _h_connection * h_connect_mariadb(const char * host, const char * user, const char * passwd, const char * db, const unsigned int port, const char * unix_socket);
void h_close_mariadb(struct _h_connection * conn);
char * h_escape_string_mariadb(const struct _h_connection * conn, const char * unsafe);
char * h_escape_string_with_quotes_mariadb(const struct _h_connection * conn, const char * unsafe);
long long int h_last_insert_id_mariadb(const struct _h_connection * conn);
int h_execute_query_json_mariadb(const struct _h_connection * conn, const char * query, json_t ** j_result);
int h_execute_query_mariadb(const struct _h_connection * conn, const char * query, struct _h_result * result);
struct _h_data * h_get_mariadb_value(const char * value, const unsigned long length, const int m_type);
struct _h_connection * h_connect_pgsql(const char * conninfo);
void h_close_pgsql(struct _h_connection * conn);
char * h_escape_string_pgsql(const struct _h_connection * conn, const char * unsafe);
char * h_escape_string_with_quotes_pgsql(const struct _h_connection * conn, const char * unsafe);
int h_execute_query_json_pgsql(const struct _h_connection * conn, const char * query, json_t ** j_result);
long long int h_last_insert_id_pgsql(const struct _h_connection * conn);
int h_execute_query_pgsql(const struct _h_connection * conn, const char * query, struct _h_result * result);
#ifdef __cplusplus
}
#endif
#endif /* __HOEL_H__ */
h_escape_string_with_quotes_sqlite
char * h_escape_string_with_quotes_sqlite(const struct _h_connection *conn, const char *unsafe)
Definition hoel-sqlite.c:342
h_escape_string_with_quotes_pgsql
char * h_escape_string_with_quotes_pgsql(const struct _h_connection *conn, const char *unsafe)
Definition hoel-pgsql.c:428
h_escape_string_pgsql
char * h_escape_string_pgsql(const struct _h_connection *conn, const char *unsafe)
Definition hoel-pgsql.c:421
h_escape_string_with_quotes
char * h_escape_string_with_quotes(const struct _h_connection *conn, const char *unsafe)
Definition hoel.c:103
h_escape_string_sqlite
char * h_escape_string_sqlite(const struct _h_connection *conn, const char *unsafe)
Definition hoel-sqlite.c:335
h_escape_string_with_quotes_mariadb
char * h_escape_string_with_quotes_mariadb(const struct _h_connection *conn, const char *unsafe)
Definition hoel-mariadb.c:460
h_escape_string
char * h_escape_string(const struct _h_connection *conn, const char *unsafe)
Definition hoel.c:73
h_escape_string_mariadb
char * h_escape_string_mariadb(const struct _h_connection *conn, const char *unsafe)
Definition hoel-mariadb.c:453
h_query_insert
int h_query_insert(const struct _h_connection *conn, const char *query)
Definition hoel.c:314
h_query_last_insert_id
struct _h_data * h_query_last_insert_id(const struct _h_connection *conn)
Definition hoel.c:327
h_query_update
int h_query_update(const struct _h_connection *conn, const char *query)
Definition hoel.c:371
h_clean_data_full
int h_clean_data_full(struct _h_data *data)
Definition hoel.c:466
h_query_select
int h_query_select(const struct _h_connection *conn, const char *query, struct _h_result *result)
Definition hoel.c:397
h_clean_data
int h_clean_data(struct _h_data *data)
Definition hoel.c:445
h_clean_result
int h_clean_result(struct _h_result *result)
Definition hoel.c:422
h_get_mariadb_value
struct _h_data * h_get_mariadb_value(const char *value, const unsigned long length, const int m_type)
Definition hoel-mariadb.c:489
h_execute_query_pgsql
int h_execute_query_pgsql(const struct _h_connection *conn, const char *query, struct _h_result *result)
Definition hoel-pgsql.c:441
h_execute_query
int h_execute_query(const struct _h_connection *conn, const char *query, struct _h_result *result, int options)
Definition hoel.c:138
h_query_delete
int h_query_delete(const struct _h_connection *conn, const char *query)
Definition hoel.c:384
h_select_query_sqlite
int h_select_query_sqlite(const struct _h_connection *conn, const char *query, struct _h_result *result)
h_execute_query_mariadb
int h_execute_query_mariadb(const struct _h_connection *conn, const char *query, struct _h_result *result)
Definition hoel-mariadb.c:473
h_connect_pgsql
struct _h_connection * h_connect_pgsql(const char *conninfo)
Definition hoel-pgsql.c:410
h_close_mariadb
void h_close_mariadb(struct _h_connection *conn)
Definition hoel-mariadb.c:448
h_clean_connection
int h_clean_connection(struct _h_connection *conn)
Definition hoel.c:633
h_connect_sqlite
struct _h_connection * h_connect_sqlite(const char *db_path)
Definition hoel-sqlite.c:324
h_connect_mariadb
struct _h_connection * h_connect_mariadb(const char *host, const char *user, const char *passwd, const char *db, const unsigned int port, const char *unix_socket)
Definition hoel-mariadb.c:437
h_close_sqlite
void h_close_sqlite(struct _h_connection *conn)
Definition hoel-sqlite.c:330
h_close_db
int h_close_db(struct _h_connection *conn)
Definition hoel.c:40
h_close_pgsql
void h_close_pgsql(struct _h_connection *conn)
Definition hoel-pgsql.c:416
h_execute_query_json_mariadb
int h_execute_query_json_mariadb(const struct _h_connection *conn, const char *query, json_t **j_result)
Definition hoel-mariadb.c:481
h_execute_query_json_pgsql
int h_execute_query_json_pgsql(const struct _h_connection *conn, const char *query, json_t **j_result)
Definition hoel-pgsql.c:449
h_last_insert_id_sqlite
long long int h_last_insert_id_sqlite(const struct _h_connection *conn)
Definition hoel-sqlite.c:349
h_execute_query_sqlite
int h_execute_query_sqlite(const struct _h_connection *conn, const char *query)
Definition hoel-sqlite.c:355
h_delete
int h_delete(const struct _h_connection *conn, const json_t *j_query, char **generated_query)
Definition hoel-simple-json.c:762
h_last_insert_id_pgsql
long long int h_last_insert_id_pgsql(const struct _h_connection *conn)
Definition hoel-pgsql.c:435
h_last_insert_id
json_t * h_last_insert_id(const struct _h_connection *conn)
Definition hoel-simple-json.c:674
h_select
int h_select(const struct _h_connection *conn, const json_t *j_query, json_t **j_result, char **generated_query)
Definition hoel-simple-json.c:458
h_exec_query_sqlite
int h_exec_query_sqlite(const struct _h_connection *conn, const char *query)
h_build_where_clause
char * h_build_where_clause(const struct _h_connection *conn, const char *pattern,...)
Definition hoel-simple-json.c:807
h_last_insert_id_mariadb
long long int h_last_insert_id_mariadb(const struct _h_connection *conn)
Definition hoel-mariadb.c:467
h_execute_query_json
int h_execute_query_json(const struct _h_connection *conn, const char *query, json_t **j_result)
Definition hoel.c:175
h_insert
int h_insert(const struct _h_connection *conn, const json_t *j_query, char **generated_query)
Definition hoel-simple-json.c:604
h_execute_query_json_sqlite
int h_execute_query_json_sqlite(const struct _h_connection *conn, const char *query, json_t **j_result)
Definition hoel-sqlite.c:362
h_update
int h_update(const struct _h_connection *conn, const json_t *j_query, char **generated_query)
Definition hoel-simple-json.c:712
h_query_select_json
int h_query_select_json(const struct _h_connection *conn, const char *query, json_t **j_result)
Definition hoel.c:410
h_free
void h_free(void *data)
Definition hoel.c:32
_h_connection
Definition hoel.h:87
_h_connection::type
int type
Definition hoel.h:88
_h_connection::connection
void * connection
Definition hoel.h:89
_h_data
Definition hoel.h:132
_h_data::type
int type
Definition hoel.h:133
_h_data::t_data
void * t_data
Definition hoel.h:134
_h_result
Definition hoel.h:140
_h_result::nb_rows
unsigned int nb_rows
Definition hoel.h:141
_h_result::data
struct _h_data ** data
Definition hoel.h:143
_h_result::nb_columns
unsigned int nb_columns
Definition hoel.h:142
_h_type_blob
Definition hoel.h:124
_h_type_blob::length
size_t length
Definition hoel.h:125
_h_type_blob::value
void * value
Definition hoel.h:126
_h_type_datetime
Definition hoel.h:109
_h_type_datetime::value
struct tm value
Definition hoel.h:110
_h_type_double
Definition hoel.h:102
_h_type_double::value
double value
Definition hoel.h:103
_h_type_int
Definition hoel.h:95
_h_type_int::value
long long int value
Definition hoel.h:96
_h_type_text
Definition hoel.h:116
_h_type_text::length
size_t length
Definition hoel.h:117
_h_type_text::value
char * value
Definition hoel.h:118