1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## db4.3.dpatch by Matej Vela <vela@debian.org>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: Port to Berkeley DB 4.3.
8
diff -urNad skksearch-0.0~/dic_db.c skksearch-0.0/dic_db.c
9
--- skksearch-0.0~/dic_db.c 2005-11-12 19:49:38.000000000 +0100
10
+++ skksearch-0.0/dic_db.c 2005-11-12 19:55:03.000000000 +0100
13
/* BerkeleyDB environment */
14
int env_initialized = 0;
16
-void errcall(const char *, char *);
18
+void errcall(const DB_ENV *, const char *, const char *);
21
struct dic *dic_db_open(struct dic *d, char *path) {
23
struct dic_db_internal *internal;
25
if (!env_initialized) {
26
- env.db_errcall = errcall;
27
- if ((errno = db_appinit(NULL, NULL, &env, DB_USE_ENVIRON)) != 0) {
28
- err(LOG_ERR, "dic_db_open: db_appinit failed\n");
29
+ if ((ret = db_env_create(&env, 0)) != 0
30
+ || (ret = env->open(env, NULL, 0, DB_USE_ENVIRON)) != 0) {
31
+ err(LOG_ERR, "dic_db_open: %s\n", db_strerror(ret));
34
+ env->set_errcall(env, errcall);
40
memset(internal, 0, sizeof(struct dic_db_internal));
43
- db_open(path, DB_UNKNOWN, DB_RDONLY, 0, &env, NULL, &(internal->db)))
45
- err(LOG_ERR, "dic_db_open(%s): %s\n", path, strerror(errno));
46
+ if ((ret = db_create(&(internal->db), env, 0)) != 0
47
+ || (ret = internal->db->open(internal->db, NULL, path, NULL,
48
+ DB_UNKNOWN, DB_RDONLY, 0)) != 0) {
49
+ err(LOG_ERR, "dic_db_open(%s): %s\n", path, db_strerror(ret));
52
d->internal = (void *)internal;
56
char *dic_db_search(struct dic *d, char *keystr, int keylen) {
58
struct dic_db_internal *internal = (struct dic_db_internal *)(d->internal);
59
DB *db = internal->db;
62
data.ulen = DIC_BUFSIZE - 1; /* -1 for '\0' */
63
data.flags = DB_DBT_USERMEM;
65
- if ((errno = db->get(db, NULL, &key, &data, 0)) == DB_NOTFOUND) {
66
+ if ((ret = db->get(db, NULL, &key, &data, 0)) == DB_NOTFOUND) {
68
- } else if (errno == 0) { /* found */
69
+ } else if (ret == 0) { /* found */
70
*((char *)(data.data) + data.size) = '\0';
71
return (char *)(data.data);
73
err(LOG_WARNING, "dic_db_search: %s (may be too long entry)\n",
81
int dic_db_close(struct dic *d) {
83
DB *db = ((struct dic_db_internal *)(d->internal))->db;
84
- if ((errno = db->close(db, 0)) != 0) {
85
- err(LOG_ERR, "dic_db_close: %s\n", strerror(errno));
86
+ if ((ret = db->close(db, 0)) != 0) {
87
+ err(LOG_ERR, "dic_db_close: %s\n", db_strerror(ret));
95
-void errcall(const char *foo, char *message) {
96
+void errcall(const DB_ENV *dbenv, const char *foo, const char *message) {
97
err(LOG_ERR, "dic_db: %s\n", message);