00001 /* 00002 * $Id$ 00003 * 00004 * Copyright (C) 2007,2008 TRUNK MOBILE 00005 * 00006 * This file is part of Kamailio, a free SIP server. 00007 * 00008 * Kamailio is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * Kamailio is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef ORA_CON_H 00024 #define ORA_CON_H 00025 00026 #include <oci.h> 00027 #include "../../db/db_pool.h" 00028 #include "../../db/db_id.h" 00029 #include "../../db/db_val.h" 00030 00031 /* Temporary -- callback data for submit_query/store_result */ 00032 struct query_data { 00033 OCIStmt** _rs; 00034 const db_val_t* _v; 00035 int _n; 00036 const db_val_t* _w; 00037 int _nw; 00038 }; 00039 typedef struct query_data query_data_t; 00040 00041 00042 struct ora_con { 00043 struct pool_con hdr; /* Standard fields */ 00044 00045 OCIError *errhp; /* Error */ 00046 OCISvcCtx *svchp; /* Server Context */ 00047 OCIEnv *envhp; /* Environment */ 00048 OCISession *authp; /* Authorized Session */ 00049 OCIServer *srvhp; /* Server */ 00050 00051 int connected; /* Authorized session started */ 00052 int bindpos; /* Last Bind handle position */ 00053 00054 query_data_t* pqdata; /* Temporary: cb data for submit_query/store_result */ 00055 00056 int uri_len; 00057 char uri[]; 00058 }; 00059 typedef struct ora_con ora_con_t; 00060 00061 00062 /* 00063 * Some convenience wrappers 00064 */ 00065 #define CON_ORA(db_con) ((ora_con_t*)db_con->tail) 00066 00067 00068 /* 00069 * Create a new connection structure, 00070 * open the Oracle connection and set reference count to 1 00071 */ 00072 ora_con_t* db_oracle_new_connection(const struct db_id* id); 00073 00074 00075 /* 00076 * Close the connection and release memory 00077 */ 00078 void db_oracle_free_connection(ora_con_t* con); 00079 00080 00081 /* 00082 * Disconnect after network error 00083 */ 00084 void db_oracle_disconnect(ora_con_t* con); 00085 00086 00087 /* 00088 * Reconnect to server (after error) 00089 */ 00090 sword db_oracle_reconnect(ora_con_t* con); 00091 00092 00093 /* 00094 * Decode oracle error 00095 */ 00096 const char* db_oracle_error(ora_con_t* con, sword status); 00097 00098 #endif /* ORA_CON_H */
1.5.6