1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* Copyright (c) The Exim Maintainers 2020 */
7 /* See the file NOTICE for conditions of use and distribution. */
9 /* This code originally came from Robert Wal. */
14 #include <whoson.h> /* Public header */
17 /*************************************************
19 *************************************************/
21 /* See local README for interface description. */
24 whoson_open(const uschar
* filename
, uschar
** errmsg
)
26 filename
= filename
; /* Keep picky compilers happy */
28 return (void *)(1); /* Just return something non-null */
32 /*************************************************
34 *************************************************/
36 /* See local README for interface description. */
39 whoson_find(void * handle
, const uschar
* filename
, uschar
* query
, int length
,
40 uschar
** result
, uschar
** errmsg
, uint
* do_cache
, const uschar
* opts
)
43 handle
= handle
; /* Keep picky compilers happy */
49 switch (wso_query(CS query
, CS buffer
, sizeof(buffer
)))
52 *result
= string_copy(buffer
); /* IP in database; return name of user */
56 return FAIL
; /* IP not in database */
59 *errmsg
= string_sprintf("WHOSON: failed to complete: %s", buffer
);
66 /*************************************************
67 * Version reporting entry point *
68 *************************************************/
70 /* See local README for interface description. */
72 #include "../version.h"
75 whoson_version_report(FILE *f
)
77 fprintf(f
, "Library version: Whoson: Runtime: %s\n", wso_version());
79 fprintf(f
, " Exim version %s\n", EXIM_VERSION_STR
);
83 static lookup_info _lookup_info
= {
84 .name
= US
"whoson", /* lookup name */
85 .type
= lookup_querystyle
, /* query-style lookup */
86 .open
= whoson_open
, /* open function */
87 .check
= NULL
, /* check function */
88 .find
= whoson_find
, /* find function */
89 .close
= NULL
, /* no close function */
90 .tidy
= NULL
, /* no tidy function */
91 .quote
= NULL
, /* no quoting function */
92 .version_report
= whoson_version_report
/* version reporting */
96 #define whoson_lookup_module_info _lookup_module_info
99 static lookup_info
*_lookup_list
[] = { &_lookup_info
};
100 lookup_module_info whoson_lookup_module_info
= { LOOKUP_MODULE_INFO_MAGIC
, _lookup_list
, 1 };
102 /* End of lookups/whoson.c */