db_cap.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2004 FhG Fokus
  5. * Copyright (C) 2007-2008 1&1 Internet AG
  6. *
  7. * This file is part of Kamailio, a free SIP server.
  8. *
  9. * Kamailio 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. * Kamailio is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*!
  24. * \file lib/srdb1/db_cap.h
  25. * \ingroup db1
  26. * \brief Data structures that represents capabilities in the database.
  27. *
  28. * This file defines data structures that represents certain database
  29. * capabilities. It also provides some macros for convenient access to this
  30. * values.
  31. */
  32. #ifndef DB1_CAP_H
  33. #define DB1_CAP_H
  34. /*! \brief
  35. * Represents the capabilities that a database driver supports.
  36. */
  37. typedef enum db_cap {
  38. DB_CAP_QUERY = 1 << 0, /*!< driver can perform queries */
  39. DB_CAP_RAW_QUERY = 1 << 1, /*!< driver can perform raw queries */
  40. DB_CAP_INSERT = 1 << 2, /*!< driver can insert data */
  41. DB_CAP_DELETE = 1 << 3, /*!< driver can delete data */
  42. DB_CAP_UPDATE = 1 << 4, /*!< driver can update data */
  43. DB_CAP_REPLACE = 1 << 5, /*!< driver can replace (also known as INSERT OR UPDATE) data */
  44. DB_CAP_FETCH = 1 << 6, /*!< driver supports fetch result queries */
  45. DB_CAP_LAST_INSERTED_ID = 1 << 7, /*!< driver can return the ID of the last insert operation */
  46. DB_CAP_INSERT_UPDATE = 1 << 8, /*!< driver can insert data into database & update on duplicate */
  47. DB_CAP_INSERT_DELAYED = 1 << 9, /*!< driver can do insert delayed */
  48. DB_CAP_AFFECTED_ROWS = 1 << 10 /*!< driver can return number of rows affected by the last query */
  49. } db_cap_t;
  50. /*! \brief
  51. * All database capabilities except raw_query, replace, insert_update and
  52. * last_inserted_id which should be checked separately when needed
  53. */
  54. #define DB_CAP_ALL (DB_CAP_QUERY | DB_CAP_INSERT | DB_CAP_DELETE | DB_CAP_UPDATE)
  55. /*! \brief
  56. * Returns true if all the capabilities in cpv are supported by module
  57. * represented by dbf, false otherwise
  58. */
  59. #define DB_CAPABILITY(dbf, cpv) (((dbf).cap & (cpv)) == (cpv))
  60. #endif /* DB1_CAP_H */