km_res.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * $Id$
  3. *
  4. * MySQL module result related functions
  5. *
  6. * Copyright (C) 2001-2003 FhG Fokus
  7. * Copyright (C) 2007-2008 1&1 Internet AG
  8. *
  9. * This file is part of Kamailio, a free SIP server.
  10. *
  11. * Kamailio is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * Kamailio is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. /*! \file
  26. * \brief DB_MYSQL :: Result related functions
  27. * \ingroup db_mysql
  28. * Module: \ref db_mysql
  29. */
  30. #ifndef KM_RES_H
  31. #define KM_RES_H
  32. #include "../../lib/srdb1/db_res.h"
  33. #include "../../lib/srdb1/db_con.h"
  34. struct my_res {
  35. MYSQL_RES* res; /*!< Actual result */
  36. MYSQL_ROW row; /*!< Actual row in the result */
  37. };
  38. /*
  39. * Some convenience wrappers
  40. */
  41. #define RES_RESULT(db_res) (((struct my_res*)((db_res)->ptr))->res)
  42. #define RES_ROW(db_res) (((struct my_res*)((db_res)->ptr))->row)
  43. /*!
  44. * \brief Fill the result structure with data from database
  45. * \param _h database connection
  46. * \param _r database result
  47. * \return 0 on success, negative on failure
  48. */
  49. int db_mysql_convert_result(const db1_con_t* _h, db1_res_t* _r);
  50. /*!
  51. * \brief Get and convert columns from a result
  52. * \param _h database connection
  53. * \param _r database result set
  54. * \return 0 on success, negative on failure
  55. */
  56. int db_mysql_get_columns(const db1_con_t* _h, db1_res_t* _r);
  57. /*!
  58. * \brief Allocate new result set with private structure
  59. * \return db1_res_t object on success, NULL on failure
  60. */
  61. db1_res_t* db_mysql_new_result(void);
  62. #endif