bdb_cmd.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_CMD_H_
  25. #define _BDB_CMD_H_
  26. /** \addtogroup bdb
  27. * @{
  28. */
  29. /*! \file
  30. * Berkeley DB :
  31. * Declaration of bdb_cmd data structure that contains BDB specific data
  32. * stored in db_cmd structures and related functions.
  33. *
  34. * \ingroup database
  35. */
  36. #include <stdarg.h>
  37. #include <sys/time.h>
  38. #include <db.h>
  39. #include "../../lib/srdb2/db_drv.h"
  40. #include "../../lib/srdb2/db_cmd.h"
  41. #include "../../lib/srdb2/db_res.h"
  42. #include "../../str.h"
  43. #include "bdb_con.h"
  44. /** Extension structure of db_cmd adding BDB specific data.
  45. * This data structure extends the generic data structure db_cmd in the
  46. * database API with data specific to the ldap driver.
  47. */
  48. typedef struct _bdb_cmd {
  49. db_drv_t gen; /**< Generic part of the data structure (must be first */
  50. bdb_con_t *bcon; /**< DB connection handle */
  51. DB *dbp; /**< DB structure handle */
  52. DBC *dbcp; /**< DB cursor handle */
  53. int next_flag;
  54. str skey;
  55. int skey_size;
  56. } bdb_cmd_t, *bdb_cmd_p;
  57. /** Creates a new bdb_cmd data structure.
  58. * This function allocates and initializes memory for a new bdb_cmd data
  59. * structure. The data structure is then attached to the generic db_cmd
  60. * structure in cmd parameter.
  61. * @param cmd A generic db_cmd structure to which the newly created bdb_cmd
  62. * structure will be attached.
  63. */
  64. int bdb_cmd(db_cmd_t* cmd);
  65. /** The main execution function in BDB SER driver.
  66. * This is the main execution function in this driver. It is executed whenever
  67. * a SER module calls db_exec and the target database of the commands is
  68. * ldap.
  69. * @param res A pointer to (optional) result structure if the command returns
  70. * a result.
  71. * @retval 0 if executed successfully
  72. * @retval A negative number if the database server failed to execute command
  73. * @retval A positive number if there was an error on client side (SER)
  74. */
  75. int bdb_cmd_exec(db_res_t* res, db_cmd_t* cmd);
  76. int bdb_cmd_first(db_res_t* res);
  77. int bdb_cmd_next(db_res_t* res);
  78. /** @} */
  79. #endif /* _BDB_CMD_H_ */