Add dynamic lookup support
[exim.git] / src / src / lookups / whoson.c
CommitLineData
0a49a7a4 1/* $Cambridge: exim/src/src/lookups/whoson.c,v 1.5 2009/11/16 19:50:38 nm4 Exp $ */
0756eb3c
PH
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
0a49a7a4 7/* Copyright (c) University of Cambridge 1995 - 2009 */
0756eb3c
PH
8/* See the file NOTICE for conditions of use and distribution. */
9
10/* This code originally came from Robert Wal. */
11
12#include "../exim.h"
13
14
0756eb3c 15#include <whoson.h> /* Public header */
0756eb3c
PH
16
17
18/*************************************************
19* Open entry point *
20*************************************************/
21
22/* See local README for interface description. */
23
e6d225ae 24static void *
0756eb3c
PH
25whoson_open(uschar *filename, uschar **errmsg)
26{
27filename = filename; /* Keep picky compilers happy */
28errmsg = errmsg;
29return (void *)(1); /* Just return something non-null */
30}
31
32
33/*************************************************
34* Find entry point *
35*************************************************/
36
37/* See local README for interface description. */
38
e6d225ae 39static int
0756eb3c
PH
40whoson_find(void *handle, uschar *filename, uschar *query, int length,
41 uschar **result, uschar **errmsg, BOOL *do_cache)
42{
43uschar buffer[80];
44handle = handle; /* Keep picky compilers happy */
45filename = filename;
46length = length;
47errmsg = errmsg;
48do_cache = do_cache;
49
50switch (wso_query(query, CS buffer, sizeof(buffer)))
51 {
52 case 0:
53 *result = string_copy(buffer); /* IP in database; return name of user */
54 return OK;
55
56 case +1:
57 return FAIL; /* IP not in database */
58
59 default:
60 *errmsg = string_sprintf("WHOSON: failed to complete: %s", buffer);
61 return DEFER;
62 }
63}
64
e6d225ae
DW
65static lookup_info _lookup_info = {
66 US"whoson", /* lookup name */
67 lookup_querystyle, /* query-style lookup */
68 whoson_open, /* open function */
69 NULL, /* check function */
70 whoson_find, /* find function */
71 NULL, /* no close function */
72 NULL, /* no tidy function */
73 NULL /* no quoting function */
74};
75
76#ifdef DYNLOOKUP
77#define whoson_lookup_module_info _lookup_module_info
78#endif
79
80static lookup_info *_lookup_list[] = { &_lookup_info };
81lookup_module_info whoson_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
0756eb3c
PH
82
83/* End of lookups/whoson.c */