Debug: feed startup "whats supported" info through normal debug channel
[exim.git] / src / src / lookups / dbmdb.c
index f3bd6d2da2d4fcc3ab0a3742c5f1899be473d6ec..c53e5555446ae342867a911751ec9f64bd45caf4 100644 (file)
@@ -3,6 +3,7 @@
 *************************************************/
 
 /* Copyright (c) University of Cambridge 1995 - 2018 */
+/* Copyright (c) The Exim Maintainers 2020 - 2021 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 #include "../exim.h"
@@ -25,11 +26,7 @@ EXIM_DB *yield = NULL;
 if ((s = Ustrrchr(dirname, '/'))) *s = '\0';
 EXIM_DBOPEN(filename, dirname, O_RDONLY, 0, &yield);
 if (!yield)
-  {
-  int save_errno = errno;
-  *errmsg = string_open_failed(errno, "%s as a %s file", filename, EXIM_DBTYPE);
-  errno = save_errno;
-  }
+  *errmsg = string_open_failed("%s as a %s file", filename, EXIM_DBTYPE);
 return yield;
 }
 
@@ -51,7 +48,6 @@ dbmdb_check(void *handle, const uschar *filename, int modemask, uid_t *owners,
   gid_t *owngroups, uschar **errmsg)
 {
 int rc;
-handle = handle;    /* Keep picky compilers happy */
 
 #if defined(USE_DB) || defined(USE_TDB) || defined(USE_GDBM)
 rc = lf_check_file(-1, filename, S_IFREG, modemask, owners, owngroups,
@@ -91,15 +87,12 @@ the keylength in order to include the terminating zero. */
 
 static int
 dbmdb_find(void * handle, const uschar * filename, const uschar * keystring,
-  int length, uschar ** result, uschar ** errmsg, uint * do_cache)
+  int length, uschar ** result, uschar ** errmsg, uint * do_cache,
+  const uschar * opts)
 {
 EXIM_DB *d = (EXIM_DB *)handle;
 EXIM_DATUM key, data;
 
-filename = filename;    /* Keep picky compilers happy */
-errmsg = errmsg;
-do_cache = do_cache;
-
 EXIM_DATUM_INIT(key);               /* Some DBM libraries require datums to */
 EXIM_DATUM_INIT(data);              /* be cleared before use. */
 EXIM_DATUM_DATA(key) = CS keystring;
@@ -124,10 +117,11 @@ return FAIL;
 
 static int
 dbmnz_find(void * handle, const uschar * filename, const uschar * keystring,
-  int length, uschar ** result, uschar ** errmsg, uint * do_cache)
+  int length, uschar ** result, uschar ** errmsg, uint * do_cache,
+  const uschar * opts)
 {
 return dbmdb_find(handle, filename, keystring, length-1, result, errmsg,
-  do_cache);
+  do_cache, opts);
 }
 
 
@@ -144,7 +138,8 @@ return dbmdb_find(handle, filename, keystring, length-1, result, errmsg,
 
 static int
 dbmjz_find(void * handle, const uschar * filename, const uschar * keystring,
-  int length, uschar ** result, uschar ** errmsg, uint * do_cache)
+  int length, uschar ** result, uschar ** errmsg, uint * do_cache,
+  const uschar * opts)
 {
 uschar *key_item, *key_buffer, *key_p;
 const uschar *key_elems = keystring;
@@ -205,7 +200,7 @@ DEBUG(D_lookup) debug_printf_indent("NUL-joined key length: %d\n", key_item_len)
 because we've calculated the real length, we need to subtract one more here */
 
 return dbmdb_find(handle, filename, key_buffer, key_item_len - 1,
-    result, errmsg, do_cache);
+    result, errmsg, do_cache, opts);
 }
 
 
@@ -232,49 +227,50 @@ EXIM_DBCLOSE((EXIM_DB *)handle);
 
 #include "../version.h"
 
-void
-dbm_version_report(FILE *f)
+gstring *
+dbm_version_report(gstring * g)
 {
 #ifdef DYNLOOKUP
-fprintf(f, "Library version: DBM: Exim version %s\n", EXIM_VERSION_STR);
+g = string_fmt_append(g, "Library version: DBM: Exim version %s\n", EXIM_VERSION_STR);
 #endif
+return g;
 }
 
 
 lookup_info dbm_lookup_info = {
-  US"dbm",                       /* lookup name */
-  lookup_absfile,                /* uses absolute file name */
-  dbmdb_open,                    /* open function */
-  dbmdb_check,                   /* check function */
-  dbmdb_find,                    /* find function */
-  dbmdb_close,                   /* close function */
-  NULL,                          /* no tidy function */
-  NULL,                          /* no quoting function */
-  dbm_version_report             /* version reporting */
+  .name = US"dbm",                     /* lookup name */
+  .type = lookup_absfile,              /* uses absolute file name */
+  .open = dbmdb_open,                  /* open function */
+  .check = dbmdb_check,                        /* check function */
+  .find = dbmdb_find,                  /* find function */
+  .close = dbmdb_close,                        /* close function */
+  .tidy = NULL,                                /* no tidy function */
+  .quote = NULL,                       /* no quoting function */
+  .version_report = dbm_version_report             /* version reporting */
 };
 
 lookup_info dbmz_lookup_info = {
-  US"dbmnz",                     /* lookup name */
-  lookup_absfile,                /* uses absolute file name */
-  dbmdb_open,      /* sic */     /* open function */
-  dbmdb_check,     /* sic */     /* check function */
-  dbmnz_find,                    /* find function */
-  dbmdb_close,     /* sic */     /* close function */
-  NULL,                          /* no tidy function */
-  NULL,                          /* no quoting function */
-  NULL                           /* no version reporting (redundant) */
+  .name = US"dbmnz",                   /* lookup name */
+  .type = lookup_absfile,              /* uses absolute file name */
+  .open = dbmdb_open,                  /* sic */     /* open function */
+  .check = dbmdb_check,                        /* sic */     /* check function */
+  .find = dbmnz_find,                  /* find function */
+  .close = dbmdb_close,                        /* sic */     /* close function */
+  .tidy = NULL,                                /* no tidy function */
+  .quote = NULL,                       /* no quoting function */
+  .version_report = NULL                           /* no version reporting (redundant) */
 };
 
 lookup_info dbmjz_lookup_info = {
-  US"dbmjz",                     /* lookup name */
-  lookup_absfile,                /* uses absolute file name */
-  dbmdb_open,      /* sic */     /* open function */
-  dbmdb_check,     /* sic */     /* check function */
-  dbmjz_find,                    /* find function */
-  dbmdb_close,     /* sic */     /* close function */
-  NULL,                          /* no tidy function */
-  NULL,                          /* no quoting function */
-  NULL                           /* no version reporting (redundant) */
+  .name = US"dbmjz",                   /* lookup name */
+  .type = lookup_absfile,              /* uses absolute file name */
+  .open = dbmdb_open,                  /* sic */     /* open function */
+  .check = dbmdb_check,                        /* sic */     /* check function */
+  .find = dbmjz_find,                  /* find function */
+  .close = dbmdb_close,                        /* sic */     /* close function */
+  .tidy = NULL,                                /* no tidy function */
+  .quote = NULL,                       /* no quoting function */
+  .version_report = NULL                           /* no version reporting (redundant) */
 };
 
 #ifdef DYNLOOKUP