Add dynamic lookup support
[exim.git] / src / src / lookupapi.h
1 /* $Cambridge$ */
2
3 /*************************************************
4 *     Exim - an Internet mail transport agent    *
5 *************************************************/
6
7 /* Copyright (c) University of Cambridge 1995 - 2009 */
8 /* See the file NOTICE for conditions of use and distribution. */
9
10
11 /* The "type" field in each item is a set of bit flags:
12
13   lookup_querystyle     => this is a query-style lookup,
14                              else single-key (+ file) style
15   lookup_absfile        => an absolute file name is required,
16                              (for single-key style only)
17 */
18
19 typedef struct lookup_info {
20   uschar *name;                   /* e.g. "lsearch" */
21   int type;                       /* query/singlekey/abs-file */
22   void *(*open)(                  /* open function */
23     uschar *,                     /* file name for those that have one */
24     uschar **);                   /* for error message */
25   BOOL (*check)(                  /* file checking function */
26     void *,                       /* handle */
27     uschar *,                     /* file name */
28     int,                          /* modemask for file checking */
29     uid_t *,                      /* owners for file checking */
30     gid_t *,                      /* owngroups for file checking */
31     uschar **);                   /* for error messages */
32   int (*find)(                    /* find function */
33     void *,                       /* handle */
34     uschar *,                     /* file name or NULL */
35     uschar *,                     /* key or query */
36     int,                          /* length of key or query */
37     uschar **,                    /* for returning answer */
38     uschar **,                    /* for error message */
39     BOOL *);                      /* to request cache cleanup */
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 } lookup_info;
47
48 /* This magic number is used by the following lookup_module_info structure
49    for checking API compatibility. It's equivalent to the string"LMM1" */
50 #define LOOKUP_MODULE_INFO_MAGIC 0x4c4d4d31
51
52 typedef struct lookup_module_info {
53   uint magic;
54   lookup_info **lookups;
55   uint lookupcount;
56 } lookup_module_info;
57
58 /* End of lookupapi.h */