dbase.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Core functions.
  3. * See db/db.h for description.
  4. *
  5. * Copyright (C) 2005 RingCentral Inc.
  6. * Created by Dmitry Semyonov <[email protected]>
  7. *
  8. *
  9. * This file is part of ser, a free SIP server.
  10. *
  11. * ser 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. * For a license to use the ser software under conditions
  17. * other than those described here, or to purchase support for this
  18. * software, please contact iptel.org by e-mail at the following addresses:
  19. * [email protected]
  20. *
  21. * ser is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #ifndef DBASE_H
  31. #define DBASE_H
  32. #include <oci.h>
  33. #include "../../lib/srdb2/db_con.h"
  34. #include "../../lib/srdb2/db_res.h"
  35. #include "../../db/db_key.h"
  36. #include "../../db/db_op.h"
  37. #include "../../db/db_val.h"
  38. /* A pointer to this structure is assigned to CON_TAIL(_h). */
  39. typedef struct _ora_con_t
  40. {
  41. union {
  42. OCIEnv *ptr;
  43. dvoid *dvoid_ptr;
  44. } env;
  45. union {
  46. OCIError *ptr;
  47. dvoid *dvoid_ptr;
  48. } err;
  49. union {
  50. OCISvcCtx *ptr;
  51. dvoid *dvoid_ptr;
  52. } svc;
  53. union {
  54. OCIStmt *ptr;
  55. dvoid *dvoid_ptr;
  56. } stmt;
  57. } ora_con_t;
  58. #define CON_ORA(_h) ((ora_con_t *)(CON_TAIL(_h)))
  59. typedef struct _ora_param_t
  60. {
  61. void *p_data;
  62. ub4 size;
  63. ub2 type;
  64. OCIInd ind;
  65. } ora_param_t;
  66. int db_use_table(db_con_t* _h, const char* _t);
  67. db_con_t* db_init(const char* _sqlurl);
  68. void db_close(db_con_t* _h);
  69. int db_query(db_con_t* _h, db_key_t* _k,
  70. db_op_t* _op, db_val_t* _v,
  71. db_key_t* _c, int _n, int _nc,
  72. db_key_t _o, db_res_t** _r);
  73. int db_raw_query(db_con_t* _h, char* _s, db_res_t** _r);
  74. int db_free_result(db_con_t* _h, db_res_t* _r);
  75. int db_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
  76. int db_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
  77. int db_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
  78. db_key_t* _uk, db_val_t* _uv, int _n, int _un);
  79. #endif /* DBASE_H */