00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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
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,
00065 cmds,
00066 params,
00067 0,
00068 0,
00069 0,
00070 0,
00071 oracle_mod_init,
00072 0,
00073 destroy,
00074 0
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 }