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
00037 #include <stdio.h>
00038 #include <unistd.h>
00039 #include <sys/stat.h>
00040
00041
00042 #include "../../str.h"
00043 #include "../../ut.h"
00044 #include "../../mem/mem.h"
00045
00046 #include "../../sr_module.h"
00047 #include "../../lib/srdb2/db_res.h"
00048 #include "../../lib/srdb2/db.h"
00049
00050 #include "bdb_lib.h"
00051 #include "bdb_con.h"
00052 #include "bdb_uri.h"
00053 #include "bdb_fld.h"
00054 #include "bdb_res.h"
00055 #include "bdb_cmd.h"
00056 #include "km_db_berkeley.h"
00057
00058 MODULE_VERSION
00059
00060 int auto_reload = 0;
00061 int log_enable = 0;
00062 int journal_roll_interval = 0;
00063
00064 static int bdb_mod_init(void);
00065 static void bdb_mod_destroy(void);
00066
00067
00068
00069
00070 static cmd_export_t cmds[] = {
00071 {"db_ctx", (cmd_function)NULL, 0, 0, 0},
00072 {"db_con", (cmd_function)bdb_con, 0, 0, 0},
00073 {"db_uri", (cmd_function)bdb_uri, 0, 0, 0},
00074 {"db_cmd", (cmd_function)bdb_cmd, 0, 0, 0},
00075 {"db_put", (cmd_function)bdb_cmd_exec, 0, 0, 0},
00076 {"db_del", (cmd_function)bdb_cmd_exec, 0, 0, 0},
00077 {"db_get", (cmd_function)bdb_cmd_exec, 0, 0, 0},
00078 {"db_upd", (cmd_function)bdb_cmd_exec, 0, 0, 0},
00079 {"db_sql", (cmd_function)bdb_cmd_exec, 0, 0, 0},
00080 {"db_first", (cmd_function)bdb_cmd_first, 0, 0, 0},
00081 {"db_next", (cmd_function)bdb_cmd_next, 0, 0, 0},
00082 {"db_res", (cmd_function)bdb_res, 0, 0, 0},
00083 {"db_fld", (cmd_function)bdb_fld, 0, 0, 0},
00084 {"db_bind_api", (cmd_function)bdb_bind_api, 0, 0, 0},
00085 {0, 0, 0, 0, 0}
00086 };
00087
00088
00089
00090
00091 static param_export_t params[] = {
00092 {"auto_reload", INT_PARAM, &auto_reload },
00093 {"log_enable", INT_PARAM, &log_enable },
00094 {"journal_roll_interval", INT_PARAM, &journal_roll_interval },
00095 {0, 0, 0}
00096 };
00097
00098 struct module_exports exports = {
00099 "db_berkeley",
00100 cmds,
00101 0,
00102 params,
00103 bdb_mod_init,
00104 0,
00105 bdb_mod_destroy,
00106 0,
00107 0
00108 };
00109
00110
00111 int mod_register(char *path, int *dlflags, void *p1, void *p2)
00112 {
00113 if(db_api_init()<0)
00114 return -1;
00115 return 0;
00116 }
00117
00118 static int bdb_mod_init(void)
00119 {
00120 bdb_params_t p;
00121
00122 p.auto_reload = auto_reload;
00123 p.log_enable = log_enable;
00124 p.cache_size = (4 * 1024 * 1024);
00125 p.journal_roll_interval = journal_roll_interval;
00126
00127 if(bdblib_init(&p))
00128 return -1;
00129
00130 return km_mod_init();
00131 }
00132
00133 static void bdb_mod_destroy(void)
00134 {
00135 km_destroy();
00136 bdblib_destroy();
00137 }
00138