Debug: feed startup "whats supported" info through normal debug channel
[exim.git] / src / src / lookups / testdb.c
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* Copyright (c) The Exim Maintainers 2020 - 2021 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9 #include "../exim.h"
10 #include "lf_functions.h"
11
12
13 /* These are not real lookup functions; they are just a way of testing the
14 rest of Exim by providing an easy way of specifying particular yields from
15 the find function. */
16
17
18 /*************************************************
19 *              Open entry point                  *
20 *************************************************/
21
22 /* See local README for interface description. */
23
24 static void *
25 testdb_open(const uschar * filename, uschar ** errmsg)
26 {
27 return (void *)(1);    /* Just return something non-null */
28 }
29
30
31
32 /*************************************************
33 *               Find entry point                 *
34 *************************************************/
35
36 /* See local README for interface description. */
37
38 static int
39 testdb_find(void * handle, const uschar * filename, const uschar * query,
40   int length, uschar ** result, uschar ** errmsg, uint * do_cache,
41   const uschar * opts)
42 {
43 if (Ustrcmp(query, "fail") == 0)
44   {
45   *errmsg = US"testdb lookup forced FAIL";
46   DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg);
47   return FAIL;
48   }
49 if (Ustrcmp(query, "defer") == 0)
50   {
51   *errmsg = US"testdb lookup forced DEFER";
52   DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg);
53   return DEFER;
54   }
55
56 if (Ustrcmp(query, "nocache") == 0) *do_cache = 0;
57
58 *result = string_copy(query);
59 return OK;
60 }
61
62
63 /*************************************************
64 *         Version reporting entry point          *
65 *************************************************/
66
67 /* See local README for interface description. */
68
69 #include "../version.h"
70
71 gstring *
72 testdb_version_report(gstring * g)
73 {
74 #ifdef DYNLOOKUP
75 g = string_fmt_append(g, "Library version: TestDB: Exim version %s\n", EXIM_VERSION_STR);
76 #endif
77 return g;
78 }
79
80
81 static lookup_info _lookup_info = {
82   .name = US"testdb",                   /* lookup name */
83   .type = lookup_querystyle,            /* query-style lookup */
84   .open = testdb_open,                  /* open function */
85   .check = NULL,                        /* check function */
86   .find = testdb_find,                  /* find function */
87   .close = NULL,                        /* no close function */
88   .tidy = NULL,                         /* no tidy function */
89   .quote = NULL,                        /* no quoting function */
90   .version_report = testdb_version_report          /* version reporting */
91 };
92
93 #ifdef DYNLOOKUP
94 #define testdb_lookup_module_info _lookup_module_info
95 #endif
96
97 static lookup_info *_lookup_list[] = { &_lookup_info };
98 lookup_module_info testdb_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
99
100 /* End of lookups/testdb.c */