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