dbtext.c
Go to the documentation of this file.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
00030
00031
00032 #include <stdio.h>
00033 #include <unistd.h>
00034
00035 #include "../../sr_module.h"
00036 #include "../../db/db.h"
00037 #include "dbtext.h"
00038 #include "dbt_lib.h"
00039 #include "dbt_api.h"
00040
00041 MODULE_VERSION
00042
00043 static int mod_init(void);
00044 static void destroy(void);
00045
00046
00047
00048
00049 int db_mode = 0;
00050
00051 int dbt_bind_api(db_func_t *dbb);
00052
00053
00054
00055
00056 static cmd_export_t cmds[] = {
00057 {"db_bind_api", (cmd_function)dbt_bind_api, 0, 0, 0, 0},
00058 {0, 0, 0, 0, 0, 0}
00059 };
00060
00061
00062
00063
00064
00065 static param_export_t params[] = {
00066 {"db_mode", INT_PARAM, &db_mode},
00067 {0, 0, 0}
00068 };
00069
00070
00071 struct module_exports exports = {
00072 "db_text",
00073 DEFAULT_DLFLAGS,
00074 cmds,
00075 params,
00076 0,
00077 0,
00078 0,
00079 0,
00080 mod_init,
00081 0,
00082 destroy,
00083 0
00084 };
00085
00086
00087 static int mod_init(void)
00088 {
00089 if(dbt_init_cache())
00090 return -1;
00091
00092
00093 return 0;
00094 }
00095
00096 static void destroy(void)
00097 {
00098 LM_DBG("destroy ...\n");
00099 dbt_cache_print(0);
00100 dbt_cache_destroy();
00101 }
00102
00103
00104
00105 int dbt_bind_api(db_func_t *dbb)
00106 {
00107 if(dbb==NULL)
00108 return -1;
00109
00110 memset(dbb, 0, sizeof(db_func_t));
00111
00112 dbb->use_table = dbt_use_table;
00113 dbb->init = dbt_init;
00114 dbb->close = dbt_close;
00115 dbb->query = (db_query_f)dbt_query;
00116 dbb->free_result = dbt_free_result;
00117 dbb->insert = (db_insert_f)dbt_insert;
00118 dbb->delete = (db_delete_f)dbt_delete;
00119 dbb->update = (db_update_f)dbt_update;
00120
00121 return 0;
00122 }
00123