db_oracle.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Oracle module interface
00005  *
00006  * Copyright (C) 2007,2008 TRUNK MOBILE
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 /*
00025  * History:
00026  * --------
00027  */
00028 
00029 #include <sys/time.h>
00030 #include <oci.h>
00031 #include "../../sr_module.h"
00032 #include "../../db/db.h"
00033 #include "dbase.h"
00034 #include "asynch.h"
00035 
00036 static int oracle_mod_init(void);
00037 static void destroy(void);
00038 static int db_oracle_bind_api(db_func_t *dbb);
00039 
00040 MODULE_VERSION
00041 
00042 
00043 /*
00044  * Oracle database module interface
00045  */
00046 static cmd_export_t cmds[] = {
00047    {"db_bind_api",         (cmd_function)db_oracle_bind_api,    0, 0, 0, 0},
00048    {0, 0, 0, 0, 0, 0}
00049 };
00050 
00051 
00052 /*
00053  * Exported parameters
00054  */
00055 static param_export_t params[] = {
00056    {"timeout", STR_PARAM|USE_FUNC_PARAM, (void*)&set_timeout },
00057    {"reconnect",  STR_PARAM|USE_FUNC_PARAM, (void*)&set_reconnect },
00058    {0, 0, 0}
00059 };
00060 
00061 
00062 struct module_exports exports = {
00063    "db_oracle",
00064    DEFAULT_DLFLAGS, /* dlopen flags */
00065    cmds,
00066    params,          /*  module parameters */
00067    0,               /* exported statistics */
00068    0,               /* exported MI functions */
00069    0,               /* exported pseudo-variables */
00070    0,               /* extra processes */
00071    oracle_mod_init, /* module initialization function */
00072    0,               /* response function*/
00073    destroy,         /* destroy function */
00074    0                /* per-child init function */
00075 };
00076 
00077 
00078 static int oracle_mod_init(void)
00079 {
00080    sword major, minor, update, patch, port;
00081 
00082    OCIClientVersion(&major, &minor, &update, &patch, &port);
00083    LM_DBG("Oracle client version is %d.%d.%d.%d.%d\n",
00084       major, minor, update, patch, port);
00085    return 0;
00086 }
00087 
00088 
00089 static void destroy(void)
00090 {
00091    LM_INFO("Oracle terminate\n");
00092    OCITerminate(OCI_DEFAULT);
00093 }
00094 
00095 
00096 static int db_oracle_bind_api(db_func_t *dbb)
00097 {
00098    if(dbb==NULL)
00099       return -1;
00100 
00101    memset(dbb, 0, sizeof(db_func_t));
00102 
00103    dbb->use_table        = db_oracle_use_table;
00104    dbb->init             = db_oracle_init;
00105    dbb->close            = db_oracle_close;
00106    dbb->query            = db_oracle_query;
00107    dbb->raw_query        = db_oracle_raw_query;
00108    dbb->free_result      = db_oracle_free_result;
00109    dbb->insert           = db_oracle_insert;
00110    dbb->delete           = db_oracle_delete; 
00111    dbb->update           = db_oracle_update;
00112 
00113    return 0;
00114 }

Generated on Tue May 22 14:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6