Copyright updates:
[exim.git] / src / src / lookupapi.h
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) The Exim Maintainers 2022 */
6 /* Copyright (c) University of Cambridge 1995 - 2015 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9
10 /* The "type" field in each item is a set of bit flags:
11
12   lookup_querystyle     => this is a query-style lookup,
13                              else single-key (+ file) style
14   lookup_absfile        => an absolute file name is required,
15                              (for single-key style only)
16 */
17
18 typedef struct lookup_info {
19   uschar *name;                   /* e.g. "lsearch" */
20   int type;                       /* query/singlekey/abs-file */
21   void *(*open)(                  /* open function */
22     const uschar *,               /* file name for those that have one */
23     uschar **);                   /* for error message */
24   BOOL (*check)(                  /* file checking function */
25     void *,                       /* handle */
26     const uschar *,               /* file name */
27     int,                          /* modemask for file checking */
28     uid_t *,                      /* owners for file checking */
29     gid_t *,                      /* owngroups for file checking */
30     uschar **);                   /* for error messages */
31   int (*find)(                    /* find function */
32     void *,                       /* handle */
33     const uschar *,               /* file name or NULL */
34     const uschar *,               /* key or query */
35     int,                          /* length of key or query */
36     uschar **,                    /* for returning answer */
37     uschar **,                    /* for error message */
38     uint *,                       /* cache TTL, seconds */
39     const uschar *);              /* options */
40   void (*close)(                  /* close function */
41     void *);                      /* handle */
42   void (*tidy)(void);             /* tidy function */
43   uschar *(*quote)(               /* quoting function */
44     uschar *,                     /* string to quote */
45     uschar *,                     /* additional data from quote name */
46     unsigned);                    /* lookup type index */
47   gstring * (*version_report)(    /* diagnostic function */
48     gstring *);                   /* string to appand to */
49 } lookup_info;
50
51 /* This magic number is used by the following lookup_module_info structure
52    for checking API compatibility. It used to be equivalent to the string"LMM3" */
53 #define LOOKUP_MODULE_INFO_MAGIC 0x4c4d4935
54 /* Version 2 adds: version_report */
55 /* Version 3 change: non/cache becomes TTL in seconds */
56 /* Version 4 add: index on quoting function */
57 /* Version 5 change: version report now adds to a gstring */
58
59 typedef struct lookup_module_info {
60   uint magic;
61   lookup_info **lookups;
62   uint lookupcount;
63 } lookup_module_info;
64
65 /* End of lookupapi.h */