X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/f6efe9ce58f5c88c63f21527255552f27a12498d..c4ceed07f17f67af7d96e7fd27c92eb374e62e19:/src/src/lookups/mysql.c diff --git a/src/src/lookups/mysql.c b/src/src/lookups/mysql.c index f2e9a1565..9511d2acb 100644 --- a/src/src/lookups/mysql.c +++ b/src/src/lookups/mysql.c @@ -1,5 +1,3 @@ -/* $Cambridge: exim/src/src/lookups/mysql.c,v 1.7 2010/03/05 15:59:29 nm4 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ @@ -13,22 +11,6 @@ functions. */ #include "../exim.h" #include "lf_functions.h" -#include "mysql.h" /* The local header */ - - -/* We can't just compile this code and allow the library mechanism to omit the -functions if they are not wanted, because we need to have the MYSQL header -available for compiling. Therefore, compile these functions only if -LOOKUP_MYSQL is defined. However, some compilers don't like compiling empty -modules, so keep them happy with a dummy when skipping the rest. Make it -reference itself to stop picky compilers complaining that it is unused, and put -in a dummy argument to stop even pickier compilers complaining about infinite -loops. */ - -#ifndef LOOKUP_MYSQL -static void dummy(int x) { dummy(x-1); } -#else - #include /* The system header */ @@ -51,7 +33,7 @@ static mysql_connection *mysql_connections = NULL; /* See local README for interface description. */ -void * +static void * mysql_open(uschar *filename, uschar **errmsg) { return (void *)(1); /* Just return something non-null */ @@ -65,7 +47,7 @@ return (void *)(1); /* Just return something non-null */ /* See local README for interface description. */ -void +static void mysql_tidy(void) { mysql_connection *cn; @@ -357,7 +339,7 @@ arguments are not used. The code to loop through a list of servers while the query is deferred with a retryable error is now in a separate function that is shared with other SQL lookups. */ -int +static int mysql_find(void *handle, uschar *filename, uschar *query, int length, uschar **result, uschar **errmsg, BOOL *do_cache) { @@ -387,7 +369,7 @@ Arguments: Returns: the processed string or NULL for a bad option */ -uschar * +static uschar * mysql_quote(uschar *s, uschar *opt) { register int c; @@ -430,6 +412,45 @@ return quoted; } -#endif /* MYSQL_LOOKUP */ +/************************************************* +* Version reporting entry point * +*************************************************/ + +/* See local README for interface description. */ + +#include "../version.h" + +void +mysql_version_report(FILE *f) +{ +fprintf(f, "Library version: MySQL: Compile: %s [%s]\n" + " Runtime: %s\n", + MYSQL_SERVER_VERSION, MYSQL_COMPILATION_COMMENT, + mysql_get_client_info()); +#ifdef DYNLOOKUP +fprintf(f, " Exim version %s\n", EXIM_VERSION_STR); +#endif +} + +/* These are the lookup_info blocks for this driver */ + +static lookup_info mysql_lookup_info = { + US"mysql", /* lookup name */ + lookup_querystyle, /* query-style lookup */ + mysql_open, /* open function */ + NULL, /* no check function */ + mysql_find, /* find function */ + NULL, /* no close function */ + mysql_tidy, /* tidy function */ + mysql_quote, /* quoting function */ + mysql_version_report /* version reporting */ +}; + +#ifdef DYNLOOKUP +#define mysql_lookup_module_info _lookup_module_info +#endif + +static lookup_info *_lookup_list[] = { &mysql_lookup_info }; +lookup_module_info mysql_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 }; /* End of lookups/mysql.c */