2010-09-04 21:33:53 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: db.h
|
|
|
|
*
|
|
|
|
* Description: Manages the interface to several DBMS's through macros
|
|
|
|
*
|
|
|
|
* Version: 0.1
|
|
|
|
* Created: 04/09/2010 20:21:06
|
|
|
|
* Revision: none
|
|
|
|
* Compiler: gcc
|
|
|
|
*
|
|
|
|
* Author: BlackLight (http://0x00.ath.cx), <blacklight@autistici.org>
|
|
|
|
* Licence: GNU GPL v.3
|
|
|
|
* Company: DO WHAT YOU WANT CAUSE A PIRATE IS FREE, YOU ARE A PIRATE!
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-16 17:11:46 +02:00
|
|
|
#ifdef HAVE_DB
|
2010-09-05 23:54:22 +02:00
|
|
|
#ifndef _AI_DB_H
|
|
|
|
#define _AI_DB_H
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-09-16 17:11:46 +02:00
|
|
|
#ifdef HAVE_LIBMYSQLCLIENT
|
2010-09-14 19:24:03 +02:00
|
|
|
#include <mysql/mysql.h>
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-09-14 19:24:03 +02:00
|
|
|
typedef MYSQL_RES* DB_result;
|
|
|
|
typedef MYSQL_ROW DB_row;
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-10-01 19:32:34 +02:00
|
|
|
#define DB_init mysql_do_init
|
|
|
|
#define DB_is_init mysql_is_init
|
|
|
|
#define DB_query mysql_do_query
|
2010-10-21 17:42:57 +02:00
|
|
|
#define DB_num_rows mysql_num_rows
|
2010-10-01 19:32:34 +02:00
|
|
|
#define DB_fetch_row mysql_fetch_row
|
|
|
|
#define DB_free_result mysql_free_result
|
|
|
|
#define DB_escape_string mysql_do_escape_string
|
|
|
|
#define DB_close mysql_do_close
|
|
|
|
|
|
|
|
#define DB_out_init mysql_do_out_init
|
|
|
|
#define DB_is_out_init mysql_is_out_init
|
|
|
|
#define DB_out_query mysql_do_out_query
|
|
|
|
#define DB_out_escape_string mysql_do_out_escape_string
|
|
|
|
#define DB_out_close mysql_do_out_close
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-09-05 23:54:22 +02:00
|
|
|
DB_result* DB_query ( const char* );
|
2010-10-01 19:32:34 +02:00
|
|
|
DB_result* DB_out_query ( const char* );
|
2010-09-16 17:11:46 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPQ
|
|
|
|
#include <postgresql/libpq-fe.h>
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-09-16 17:11:46 +02:00
|
|
|
typedef struct {
|
|
|
|
PGresult *res;
|
|
|
|
int index;
|
|
|
|
char ***rows;
|
|
|
|
} PSQL_result;
|
|
|
|
|
|
|
|
typedef PSQL_result* DB_result;
|
|
|
|
typedef char** DB_row;
|
|
|
|
|
2010-10-05 04:01:35 +02:00
|
|
|
#define DB_init postgresql_do_init
|
|
|
|
#define DB_is_init postgresql_is_init
|
|
|
|
#define DB_query postgresql_do_query
|
|
|
|
#define DB_num_rows postgresql_num_rows
|
|
|
|
#define DB_fetch_row postgresql_fetch_row
|
|
|
|
#define DB_free_result postgresql_free_result
|
|
|
|
#define DB_escape_string postgresql_do_escape_string
|
|
|
|
#define DB_close postgresql_do_close
|
|
|
|
|
|
|
|
#define DB_out_init postgresql_do_out_init
|
|
|
|
#define DB_is_out_init postgresql_is_out_init
|
|
|
|
#define DB_out_query postgresql_do_out_query
|
|
|
|
#define DB_out_escape_string postgresql_do_out_escape_string
|
|
|
|
#define DB_out_close postgresql_do_out_close
|
2010-10-01 19:32:34 +02:00
|
|
|
|
2010-09-16 17:11:46 +02:00
|
|
|
int DB_num_rows ( PSQL_result *res );
|
|
|
|
DB_row DB_fetch_row ( PSQL_result *res );
|
|
|
|
void DB_free_result ( PSQL_result *res );
|
|
|
|
DB_result DB_query ( const char* );
|
2010-10-01 19:32:34 +02:00
|
|
|
DB_result DB_out_query ( const char* );
|
2010-09-16 17:11:46 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-01 19:32:34 +02:00
|
|
|
void* DB_init();
|
2010-10-04 17:48:07 +02:00
|
|
|
unsigned long DB_escape_string ( char **to, const char *from, unsigned long length );
|
2010-10-01 19:32:34 +02:00
|
|
|
void DB_close();
|
|
|
|
|
|
|
|
void* DB_out_init();
|
2010-10-04 17:48:07 +02:00
|
|
|
unsigned long DB_out_escape_string ( char **to, const char *from, unsigned long length );
|
2010-10-01 19:32:34 +02:00
|
|
|
void DB_out_close();
|
2010-09-04 21:33:53 +02:00
|
|
|
|
2010-09-05 23:54:22 +02:00
|
|
|
#endif
|
2010-09-04 21:33:53 +02:00
|
|
|
#endif
|
|
|
|
|