db_drv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG FOKUS
  5. * Copyright (C) 2006-2007 iptelorg GmbH
  6. *
  7. * This file is part of ser, a free SIP server.
  8. *
  9. * ser is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * For a license to use the ser software under conditions
  15. * other than those described here, or to purchase support for this
  16. * software, please contact iptel.org by e-mail at the following addresses:
  17. * [email protected]
  18. *
  19. * ser is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  27. */
  28. #ifndef _DB_DRV_H
  29. #define _DB_DRV_H 1
  30. /** \ingroup DB_API
  31. * @{
  32. */
  33. #include "db_gen.h"
  34. #include "../../str.h"
  35. #include "../../list.h"
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif /* __cplusplus */
  39. struct db_drv;
  40. struct db_gen;
  41. typedef void db_drv_free_t(struct db_gen* db_struct, struct db_drv* payload);
  42. /*
  43. * Generic function exported by DB driver modules
  44. */
  45. typedef int (*db_drv_func_t)(void* db_struct, ...);
  46. /* Template for driver specific data that can be attached to various
  47. * DB API structure and where drivers can store driver-specific data
  48. */
  49. typedef struct db_drv {
  50. db_drv_free_t* free; /* Drivers must provide this function */
  51. } db_drv_t;
  52. int db_drv_init(struct db_drv* ptr, void* free_func);
  53. void db_drv_free(struct db_drv* ptr);
  54. /*
  55. * Find function with given name in module named <module>
  56. * RETURNS: -1 on error
  57. * 0 if a function has been found
  58. * 1 if no function has been found
  59. */
  60. int db_drv_func(db_drv_func_t* func, str* module, char* func_name);
  61. /*
  62. * Call function with name <func_name> in DB driver <module>, give
  63. * it pointer <db_struct> as the pointer to the corresponding DB structure
  64. * (type of the structure is function-specific) and <offset> is the offset
  65. * of the driver/connection within the context (used to make DB_DRV_ATTACH
  66. * and DB_DRV_DATA macros work)
  67. */
  68. int db_drv_call(str* module, char* func_name, void* db_struct, int offset);
  69. #ifdef __cplusplus
  70. }
  71. #endif /* __cplusplus */
  72. /** @} */
  73. #endif /* _DB_DRV_H */