Update copyright year in (most) files (those that my script finds).
[exim.git] / src / src / lookups / whoson.c
CommitLineData
d7d7b7b9 1/* $Cambridge: exim/src/src/lookups/whoson.c,v 1.3 2006/02/07 11:19:01 ph10 Exp $ */
0756eb3c
PH
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
d7d7b7b9 7/* Copyright (c) University of Cambridge 1995 - 2006 */
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
15/* We can't just compile this code and allow the library mechanism to omit the
16functions if they are not wanted, because we need to have the WHOSON headers
17available for compiling. Therefore, compile these functions only if
18LOOKUP_WHOSON is defined. However, some compilers don't like compiling empty
19modules, so keep them happy with a dummy when skipping the rest. Make it
20reference itself to stop picky compilers complaining that it is unused, and put
21in a dummy argument to stop even pickier compilers complaining about infinite
22loops. */
23
24#ifndef LOOKUP_WHOSON
25static void dummy(int x) { dummy(x-1); }
26#else
27
28
29#include <whoson.h> /* Public header */
30#include "whoson.h" /* Local header */
31
32
33/*************************************************
34* Open entry point *
35*************************************************/
36
37/* See local README for interface description. */
38
39void *
40whoson_open(uschar *filename, uschar **errmsg)
41{
42filename = filename; /* Keep picky compilers happy */
43errmsg = errmsg;
44return (void *)(1); /* Just return something non-null */
45}
46
47
48/*************************************************
49* Find entry point *
50*************************************************/
51
52/* See local README for interface description. */
53
54int
55whoson_find(void *handle, uschar *filename, uschar *query, int length,
56 uschar **result, uschar **errmsg, BOOL *do_cache)
57{
58uschar buffer[80];
59handle = handle; /* Keep picky compilers happy */
60filename = filename;
61length = length;
62errmsg = errmsg;
63do_cache = do_cache;
64
65switch (wso_query(query, CS buffer, sizeof(buffer)))
66 {
67 case 0:
68 *result = string_copy(buffer); /* IP in database; return name of user */
69 return OK;
70
71 case +1:
72 return FAIL; /* IP not in database */
73
74 default:
75 *errmsg = string_sprintf("WHOSON: failed to complete: %s", buffer);
76 return DEFER;
77 }
78}
79
80#endif /* LOOKUP_WHOSON */
81
82/* End of lookups/whoson.c */