bdb_con.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Id$
  3. *
  4. * BDB Database Driver for SIP-router
  5. *
  6. * Copyright (C) 2008 iptelorg GmbH
  7. *
  8. * This file is part of SIP-router, a free SIP server.
  9. *
  10. * SIP-router is free software; you can redistribute it and/or modify it under the
  11. * terms of the GNU General Public License as published by the Free Software
  12. * Foundation; either version 2 of the License, or (at your option) any later
  13. * version.
  14. *
  15. * SIP-router is distributed in the hope that it will be useful, but WITHOUT ANY
  16. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. */
  24. #ifndef _BDB_CON_H_
  25. #define _BDB_CON_H_
  26. /** \addtogroup bdb
  27. * @{
  28. */
  29. /*! \file
  30. * Berkeley DB : Implementation of BDB per-connection related data structures and functions.
  31. *
  32. * \ingroup database
  33. */
  34. #include <time.h>
  35. #include <db.h>
  36. #include "../../lib/srdb2/db_pool.h"
  37. #include "../../lib/srdb2/db_con.h"
  38. #include "../../lib/srdb2/db_uri.h"
  39. #include "bdb_lib.h"
  40. /**
  41. * Per-connection flags for BDB connections.
  42. */
  43. enum bdb_con_flags {
  44. BDB_CONNECTED = (1 << 0), /**< The connection has been connected successfully */
  45. };
  46. /** A structure representing a connection to a BDB.
  47. * This structure represents connections to BDB. It contains
  48. * BDB specific per-connection data,
  49. */
  50. typedef struct _bdb_con {
  51. db_pool_entry_t gen; /**< Generic part of the structure */
  52. bdb_db_t *dbp; /**< DB structure handle */
  53. unsigned int flags; /**< Flags */
  54. } bdb_con_t, *bdb_con_p;
  55. /** Create a new bdb_con structure.
  56. * This function creates a new bdb_con structure and attachs the structure to
  57. * the generic db_con structure in the parameter.
  58. * @param con A generic db_con structure to be extended with BDB payload
  59. * @retval 0 on success
  60. * @retval A negative number on error
  61. */
  62. int bdb_con(db_con_t* con);
  63. /** Establish a new connection to server.
  64. * This function is called when a SER module calls db_connect to establish a
  65. * new connection to the database server.
  66. * @param con A structure representing database connection.
  67. * @retval 0 on success.
  68. * @retval A negative number on error.
  69. */
  70. int bdb_con_connect(db_con_t* con);
  71. /** Disconnected from BDB.
  72. * Disconnects a previously connected connection to BDB.
  73. * @param con A structure representing the connection to be disconnected.
  74. */
  75. void bdb_con_disconnect(db_con_t* con);
  76. /** @} */
  77. #endif /* _BDB_CON_H_ */