ora_con.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2007,2008 TRUNK MOBILE
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef ORA_CON_H
  23. #define ORA_CON_H
  24. #include <oci.h>
  25. #include "../../lib/srdb1/db_pool.h"
  26. #include "../../lib/srdb1/db_id.h"
  27. #include "../../lib/srdb1/db_val.h"
  28. /* Temporary -- callback data for submit_query/store_result */
  29. struct query_data {
  30. OCIStmt** _rs;
  31. const db_val_t* _v;
  32. int _n;
  33. const db_val_t* _w;
  34. int _nw;
  35. };
  36. typedef struct query_data query_data_t;
  37. struct ora_con {
  38. struct pool_con hdr; /* Standard fields */
  39. OCIError *errhp; /* Error */
  40. OCISvcCtx *svchp; /* Server Context */
  41. OCIEnv *envhp; /* Environment */
  42. OCISession *authp; /* Authorized Session */
  43. OCIServer *srvhp; /* Server */
  44. int connected; /* Authorized session started */
  45. int bindpos; /* Last Bind handle position */
  46. query_data_t* pqdata; /* Temporary: cb data for submit_query/store_result */
  47. int uri_len;
  48. char uri[];
  49. };
  50. typedef struct ora_con ora_con_t;
  51. /*
  52. * Some convenience wrappers
  53. */
  54. #define CON_ORA(db_con) ((ora_con_t*)db_con->tail)
  55. /*
  56. * Create a new connection structure,
  57. * open the Oracle connection and set reference count to 1
  58. */
  59. ora_con_t* db_oracle_new_connection(const struct db_id* id);
  60. /*
  61. * Close the connection and release memory
  62. */
  63. void db_oracle_free_connection(ora_con_t* con);
  64. /*
  65. * Disconnect after network error
  66. */
  67. void db_oracle_disconnect(ora_con_t* con);
  68. /*
  69. * Reconnect to server (after error)
  70. */
  71. sword db_oracle_reconnect(ora_con_t* con);
  72. /*
  73. * Decode oracle error
  74. */
  75. const char* db_oracle_error(ora_con_t* con, sword status);
  76. #endif /* ORA_CON_H */