00001 /* 00002 * $Id: my_con.h 4518 2008-07-28 15:39:28Z henningw $ 00003 * 00004 * Copyright (C) 2001-2003 FhG Fokus 00005 * Copyright (C) 2008 1&1 Internet AG 00006 * 00007 * This file is part of Kamailio, a free SIP server. 00008 * 00009 * Kamailio is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version 00013 * 00014 * Kamailio is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 /*! \file 00025 * \brief DB_MYSQL :: Core 00026 * \ref my_con.c 00027 * \ingroup db_mysql 00028 * Module: \ref db_mysql 00029 */ 00030 00031 00032 #ifndef MY_CON_H 00033 #define MY_CON_H 00034 00035 #include "../../db/db_pool.h" 00036 #include "../../db/db_id.h" 00037 00038 #include <time.h> 00039 #include <mysql/mysql.h> 00040 00041 00042 struct my_con { 00043 struct db_id* id; /*!< Connection identifier */ 00044 unsigned int ref; /*!< Reference count */ 00045 struct pool_con* next; /*!< Next connection in the pool */ 00046 00047 MYSQL_RES* res; /*!< Actual result */ 00048 MYSQL* con; /*!< Connection representation */ 00049 MYSQL_ROW row; /*!< Actual row in the result */ 00050 time_t timestamp; /*!< Timestamp of last query */ 00051 }; 00052 00053 00054 /* 00055 * Some convenience wrappers 00056 */ 00057 #define CON_RESULT(db_con) (((struct my_con*)((db_con)->tail))->res) 00058 #define CON_CONNECTION(db_con) (((struct my_con*)((db_con)->tail))->con) 00059 #define CON_ROW(db_con) (((struct my_con*)((db_con)->tail))->row) 00060 #define CON_TIMESTAMP(db_con) (((struct my_con*)((db_con)->tail))->timestamp) 00061 00062 00063 /*! \brief 00064 * Create a new connection structure, 00065 * open the MySQL connection and set reference count to 1 00066 */ 00067 struct my_con* db_mysql_new_connection(const struct db_id* id); 00068 00069 00070 /*! \brief 00071 * Close the connection and release memory 00072 */ 00073 void db_mysql_free_connection(struct pool_con* con); 00074 00075 #endif /* MY_CON_H */
1.5.6