1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) The Exim Maintainers 2020 - 2022 */
6 /* Copyright (c) University of Cambridge 1995 - 2015 */
7 /* See the file NOTICE for conditions of use and distribution. */
8 /* SPDX-License-Identifier: GPL-2.0-or-later */
11 #include "lf_functions.h"
14 /* These are not real lookup functions; they are just a way of testing the
15 rest of Exim by providing an easy way of specifying particular yields from
19 /*************************************************
21 *************************************************/
23 /* See local README for interface description. */
26 testdb_open(const uschar * filename, uschar ** errmsg)
28 return (void *)(1); /* Just return something non-null */
33 /*************************************************
35 *************************************************/
37 /* See local README for interface description. */
40 testdb_find(void * handle, const uschar * filename, const uschar * query,
41 int length, uschar ** result, uschar ** errmsg, uint * do_cache,
44 if (Ustrcmp(query, "fail") == 0)
46 *errmsg = US"testdb lookup forced FAIL";
47 DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg);
50 if (Ustrcmp(query, "defer") == 0)
52 *errmsg = US"testdb lookup forced DEFER";
53 DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg);
57 if (Ustrcmp(query, "nocache") == 0) *do_cache = 0;
59 *result = string_copy(query);
64 /*************************************************
65 * Version reporting entry point *
66 *************************************************/
68 /* See local README for interface description. */
70 #include "../version.h"
73 testdb_version_report(gstring * g)
76 g = string_fmt_append(g, "Library version: TestDB: Exim version %s\n", EXIM_VERSION_STR);
82 static lookup_info _lookup_info = {
83 .name = US"testdb", /* lookup name */
84 .type = lookup_querystyle, /* query-style lookup */
85 .open = testdb_open, /* open function */
86 .check = NULL, /* check function */
87 .find = testdb_find, /* find function */
88 .close = NULL, /* no close function */
89 .tidy = NULL, /* no tidy function */
90 .quote = NULL, /* no quoting function */
91 .version_report = testdb_version_report /* version reporting */
95 #define testdb_lookup_module_info _lookup_module_info
98 static lookup_info *_lookup_list[] = { &_lookup_info };
99 lookup_module_info testdb_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
101 /* End of lookups/testdb.c */