db_id.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2005 iptel.org
  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_id.h
  25. * \ingroup db1
  26. * \brief Functions for parsing a database URL and works with db identifier.
  27. */
  28. #ifndef _DB1_ID_H
  29. #define _DB1_ID_H
  30. #include "../../str.h"
  31. #include "db_pooling.h"
  32. /** Structure representing a database ID */
  33. struct db_id {
  34. str url; /**< full URL clone */
  35. char* scheme; /**< URL scheme */
  36. char* username; /**< Username, case sensitive */
  37. char* password; /**< Password, case sensitive */
  38. char* host; /**< Host or IP, case insensitive */
  39. unsigned short port; /**< Port number */
  40. char* database; /**< Database, case sensitive */
  41. int pid; /**< Process ID (detect cross connections) */
  42. int poolid; /**< poolid within a pid */
  43. };
  44. /**
  45. * Create a new connection identifier
  46. * \param url database URL
  47. * \param pooling whether or not a pooled connection may be used
  48. * \return new allocated db_id structure, NULL on failure
  49. */
  50. struct db_id* new_db_id(const str* url, db_pooling_t pooling);
  51. /**
  52. * Compare two connection identifiers
  53. * \param id1 first identifier
  54. * \param id2 second identifier
  55. * \return 1 if both identifier are equal, 0 if there not equal
  56. */
  57. unsigned char cmp_db_id(const struct db_id* id1, const struct db_id* id2);
  58. /**
  59. * Free a connection identifier
  60. * \param id the identifier that should released
  61. */
  62. void free_db_id(struct db_id* id);
  63. #endif /* _DB1_ID_H */