Report compiler in -d -bV. Clang compat.
[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
b3c261f7 50switch (wso_query(CS query, CS buffer, sizeof(buffer)))
0756eb3c
PH
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
6545de78
PP
65
66
67/*************************************************
68* Version reporting entry point *
69*************************************************/
70
71/* See local README for interface description. */
72
73#include "../version.h"
74
75void
76whoson_version_report(FILE *f)
77{
78fprintf(f, "Library version: Whoson: Runtime: %s\n", wso_version());
79#ifdef DYNLOOKUP
80fprintf(f, " Exim version %s\n", EXIM_VERSION_STR);
81#endif
82}
83
e6d225ae
DW
84static lookup_info _lookup_info = {
85 US"whoson", /* lookup name */
86 lookup_querystyle, /* query-style lookup */
87 whoson_open, /* open function */
88 NULL, /* check function */
89 whoson_find, /* find function */
90 NULL, /* no close function */
91 NULL, /* no tidy function */
6545de78
PP
92 NULL, /* no quoting function */
93 whoson_version_report /* version reporting */
e6d225ae
DW
94};
95
96#ifdef DYNLOOKUP
97#define whoson_lookup_module_info _lookup_module_info
98#endif
99
100static lookup_info *_lookup_list[] = { &_lookup_info };
101lookup_module_info whoson_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
0756eb3c
PH
102
103/* End of lookups/whoson.c */