Add dynamic lookup support
[exim.git] / src / src / lookups / oracle.c
index b438b3bb1e11e99d0ad50e29b6fbdbb6b8651990..50dfb4aeeb7bce2b666bd393f3ebdfde5f9344d7 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/lookups/oracle.c,v 1.1 2004/10/07 13:10:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/lookups/oracle.c,v 1.6 2009/11/16 19:50:38 nm4 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2009 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Interface to an Oracle database. This code was originally supplied by
@@ -15,36 +15,26 @@ some comments from my position of Oracle ignorance. */
 #include "../exim.h"
 
 
-/* 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 ORACLE headers
-available for compiling. Therefore, compile these functions only if
-LOOKUP_ORACLE 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_ORACLE
-static void dummy(int x) { dummy(x-1); }
-#else
-
 /* The Oracle system headers */
 
 #include <oratypes.h>
 #include <ocidfn.h>
 #include <ocikpr.h>
 
-#include "oracle.h"                    /* The local header */
-
 #define PARSE_NO_DEFER           0     /* parse straight away */
 #define PARSE_V7_LNG             2
 #define MAX_ITEM_BUFFER_SIZE  1024     /* largest size of a cell of data */
 #define MAX_SELECT_LIST_SIZE    32     /* maximum number of columns (not rows!) */
 
 /* Paul's comment on this was "change this to 512 for 64bit cpu", but I don't
-understand why. The Oracle manual just asks for 256 bytes. */
+understand why. The Oracle manual just asks for 256 bytes.
 
-#define HDA_SIZE 256
+That was years ago. Jin Choi suggested (March 2007) that this change should
+be made in the source, as at worst it wastes 256 bytes, and it saves people
+having to discover about this for themselves as more and more systems are
+64-bit. So I have changed 256 to 512. */
+
+#define HDA_SIZE 512
 
 /* Internal/external datatype codes */
 
@@ -207,7 +197,7 @@ return col;
 
 /* See local README for interface description. */
 
-void *
+static void *
 oracle_open(uschar *filename, uschar **errmsg)
 {
 return (void *)(1);    /* Just return something non-null */
@@ -221,7 +211,7 @@ return (void *)(1);    /* Just return something non-null */
 
 /* See local README for interface description. */
 
-void
+static void
 oracle_tidy(void)
 {
 oracle_connection *cn;
@@ -527,7 +517,7 @@ else
 arguments are not used. Loop through a list of servers while the query is
 deferred with a retryable error. */
 
-int
+static int
 oracle_find(void *handle, uschar *filename, uschar *query, int length,
   uschar **result, uschar **errmsg, BOOL *do_cache)
 {
@@ -572,7 +562,7 @@ Arguments:
 Returns:     the processed string or NULL for a bad option
 */
 
-uschar *
+static uschar *
 oracle_quote(uschar *s, uschar *opt)
 {
 register int c;
@@ -614,6 +604,22 @@ while ((c = *s++) != 0)
 return quoted;
 }
 
-#endif  /* LOOKUP_ORACLE */
+static lookup_info _lookup_info = {
+  US"oracle",                    /* lookup name */
+  lookup_querystyle,             /* query-style lookup */
+  oracle_open,                   /* open function */
+  NULL,                          /* check function */
+  oracle_find,                   /* find function */
+  NULL,                          /* no close function */
+  oracle_tidy,                   /* tidy function */
+  oracle_quote                   /* quoting function */
+};
+
+#ifdef DYNLOOKUP
+#define oracle_lookup_module_info _lookup_module_info
+#endif
+
+static lookup_info *_lookup_list[] = { &_lookup_info };
+lookup_module_info oracle_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
 
 /* End of lookups/oracle.c */