modules_k/db_unixodbc/dbase.h

00001 /*
00002  * $Id$
00003  *
00004  * UNIXODBC module core functions
00005  *
00006  * Copyright (C) 2005-2006 Marco Lorrai
00007  * Copyright (C) 2008 1&1 Internet AG
00008  *
00009  * This file is part of Kamailio, a free SIP server.
00010  *
00011  * Kamailio is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version
00015  *
00016  * Kamailio is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  *
00026  * History:
00027  * --------
00028  *  2005-12-01  initial commit (chgen)
00029  */
00030 
00031 
00032 #ifndef DBASE_H
00033 #define DBASE_H
00034 
00035 #include "../../lib/srdb1/db_con.h"
00036 #include "../../lib/srdb1/db_res.h"
00037 #include "../../lib/srdb1/db_key.h"
00038 #include "../../lib/srdb1/db_op.h"
00039 #include "../../lib/srdb1/db_val.h"
00040 
00041 /*
00042  * Initialize database connection
00043  */
00044 db1_con_t* db_unixodbc_init(const str* _sqlurl);
00045 
00046 /*
00047  * Close a database connection
00048  */
00049 void db_unixodbc_close(db1_con_t* _h);
00050 
00051 /*
00052  * Free all memory allocated by get_result
00053  */
00054 int db_unixodbc_free_result(db1_con_t* _h, db1_res_t* _r);
00055 
00056 /*
00057  * Do a query
00058  */
00059 int db_unixodbc_query(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _op, const db_val_t* _v,
00060 const db_key_t* _c, const int _n, const int _nc, const db_key_t _o, db1_res_t** _r);
00061 
00062 /*
00063  * Fetch rows from a result
00064  */
00065 int db_unixodbc_fetch_result(const db1_con_t* _h, db1_res_t** _r, const int nrows);
00066 
00067 /*
00068  * Raw SQL query
00069  */
00070 int db_unixodbc_raw_query(const db1_con_t* _h, const str* _s, db1_res_t** _r);
00071 
00072 /*
00073  * Insert a row into table
00074  */
00075 int db_unixodbc_insert(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n);
00076 
00077 /*
00078  * Delete a row from table
00079  */
00080 int db_unixodbc_delete(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v,
00081 const int _n);
00082 
00083 /*
00084  * Update a row in table
00085  */
00086 int db_unixodbc_update(const db1_con_t* _h, const db_key_t* _k, const db_op_t* _o, const db_val_t* _v,
00087 const db_key_t* _uk, const db_val_t* _uv, const int _n, const int _un);
00088 
00089 /*
00090  * Just like insert, but replace the row if it exists
00091  */
00092 int db_unixodbc_replace(const db1_con_t* handle, const db_key_t* keys, const db_val_t* vals,
00093                 const int n, const int _un, const int _m);
00094 
00095 /*
00096  * Store name of table that will be used by
00097  * subsequent database functions
00098  */
00099 int db_unixodbc_use_table(db1_con_t* _h, const str* _t);
00100 
00101 #endif                                                      /* DBASE_H */