Start
[exim.git] / src / src / lookups / testdb.c
CommitLineData
0756eb3c
PH
1/* $Cambridge: exim/src/src/lookups/testdb.c,v 1.1 2004/10/07 13:10:01 ph10 Exp $ */
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
7/* Copyright (c) University of Cambridge 1995 - 2004 */
8/* See the file NOTICE for conditions of use and distribution. */
9
10#include "../exim.h"
11#include "lf_functions.h"
12#include "testdb.h"
13
14
15/* These are not real lookup functions; they are just a way of testing the
16rest of Exim by providing an easy way of specifying particular yields from
17the find function. */
18
19
20/*************************************************
21* Open entry point *
22*************************************************/
23
24/* See local README for interface description. */
25
26void *
27testdb_open(uschar *filename, uschar **errmsg)
28{
29filename = filename; /* Keep picky compilers happy */
30errmsg = errmsg;
31return (void *)(1); /* Just return something non-null */
32}
33
34
35
36/*************************************************
37* Find entry point *
38*************************************************/
39
40/* See local README for interface description. */
41
42int
43testdb_find(void *handle, uschar *filename, uschar *query, int length,
44 uschar **result, uschar **errmsg, BOOL *do_cache)
45{
46handle = handle; /* Keep picky compilers happy */
47filename = filename;
48length = length;
49
50if (Ustrcmp(query, "fail") == 0)
51 {
52 *errmsg = US"testdb lookup forced FAIL";
53 DEBUG(D_lookup) debug_printf("%s\n", *errmsg);
54 return FAIL;
55 }
56if (Ustrcmp(query, "defer") == 0)
57 {
58 *errmsg = US"testdb lookup forced DEFER";
59 DEBUG(D_lookup) debug_printf("%s\n", *errmsg);
60 return DEFER;
61 }
62
63if (Ustrcmp(query, "nocache") == 0) *do_cache = FALSE;
64
65*result = string_copy(query);
66return OK;
67}
68
69/* End of lookups/testdb.c */