Commit | Line | Data |
---|---|---|
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 | 24 | static void * |
0756eb3c PH |
25 | whoson_open(uschar *filename, uschar **errmsg) |
26 | { | |
27 | filename = filename; /* Keep picky compilers happy */ | |
28 | errmsg = errmsg; | |
29 | return (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 | 39 | static int |
0756eb3c PH |
40 | whoson_find(void *handle, uschar *filename, uschar *query, int length, |
41 | uschar **result, uschar **errmsg, BOOL *do_cache) | |
42 | { | |
43 | uschar buffer[80]; | |
44 | handle = handle; /* Keep picky compilers happy */ | |
45 | filename = filename; | |
46 | length = length; | |
47 | errmsg = errmsg; | |
48 | do_cache = do_cache; | |
49 | ||
50 | switch (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 |
65 | static 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 | ||
80 | static lookup_info *_lookup_list[] = { &_lookup_info }; | |
81 | lookup_module_info whoson_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 }; | |
0756eb3c PH |
82 | |
83 | /* End of lookups/whoson.c */ |