Commit | Line | Data |
---|---|---|
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 | |
13 | rest of Exim by providing an easy way of specifying particular yields from | |
14 | the find function. */ | |
15 | ||
16 | ||
17 | /************************************************* | |
18 | * Open entry point * | |
19 | *************************************************/ | |
20 | ||
21 | /* See local README for interface description. */ | |
22 | ||
e6d225ae | 23 | static void * |
0756eb3c PH |
24 | testdb_open(uschar *filename, uschar **errmsg) |
25 | { | |
26 | filename = filename; /* Keep picky compilers happy */ | |
27 | errmsg = errmsg; | |
28 | return (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 | 39 | static int |
55414b25 | 40 | testdb_find(void *handle, uschar *filename, const uschar *query, int length, |
14b3c5bc | 41 | uschar **result, uschar **errmsg, uint *do_cache) |
0756eb3c PH |
42 | { |
43 | handle = handle; /* Keep picky compilers happy */ | |
44 | filename = filename; | |
45 | length = length; | |
46 | ||
47 | if (Ustrcmp(query, "fail") == 0) | |
48 | { | |
49 | *errmsg = US"testdb lookup forced FAIL"; | |
42c7f0b4 | 50 | DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg); |
0756eb3c PH |
51 | return FAIL; |
52 | } | |
53 | if (Ustrcmp(query, "defer") == 0) | |
54 | { | |
55 | *errmsg = US"testdb lookup forced DEFER"; | |
42c7f0b4 | 56 | DEBUG(D_lookup) debug_printf_indent("%s\n", *errmsg); |
0756eb3c PH |
57 | return DEFER; |
58 | } | |
59 | ||
14b3c5bc | 60 | if (Ustrcmp(query, "nocache") == 0) *do_cache = 0; |
0756eb3c PH |
61 | |
62 | *result = string_copy(query); | |
63 | return OK; | |
64 | } | |
65 | ||
6545de78 PP |
66 | |
67 | /************************************************* | |
68 | * Version reporting entry point * | |
69 | *************************************************/ | |
70 | ||
71 | /* See local README for interface description. */ | |
72 | ||
73 | #include "../version.h" | |
74 | ||
75 | void | |
76 | testdb_version_report(FILE *f) | |
77 | { | |
78 | #ifdef DYNLOOKUP | |
79 | fprintf(f, "Library version: TestDB: Exim version %s\n", EXIM_VERSION_STR); | |
80 | #endif | |
81 | } | |
82 | ||
83 | ||
e6d225ae DW |
84 | static lookup_info _lookup_info = { |
85 | US"testdb", /* lookup name */ | |
86 | lookup_querystyle, /* query-style lookup */ | |
87 | testdb_open, /* open function */ | |
88 | NULL, /* check function */ | |
89 | testdb_find, /* find function */ | |
90 | NULL, /* no close function */ | |
91 | NULL, /* no tidy function */ | |
6545de78 PP |
92 | NULL, /* no quoting function */ |
93 | testdb_version_report /* version reporting */ | |
e6d225ae DW |
94 | }; |
95 | ||
96 | #ifdef DYNLOOKUP | |
97 | #define testdb_lookup_module_info _lookup_module_info | |
98 | #endif | |
99 | ||
100 | static lookup_info *_lookup_list[] = { &_lookup_info }; | |
101 | lookup_module_info testdb_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 }; | |
102 | ||
0756eb3c | 103 | /* End of lookups/testdb.c */ |